Last updated: 4 Nov 2003
In order to add a new line to a repeating panel the focus (cursor) must be in the repeating panel. This means that your macro will either have to tab into the panel, or you need to attach it to a button which is in the repeating panel such that it appears on every line of the panel.
A neater approach is to use a script, such as this one submitted by Paul Bent. Paul writes:
"This code is attached to a "New Line" button on an Orders form. The ProductID field is first in the rp's tab order. If the field in the first row is empty there are no existing order lines. In this case it just has to set focus in the first row to start a new record. If there are rows, it sets focus in the first one then starts a new record."
Sub Click(Source As Button, X As Long, Y As Long, Flags As Long) On Error Goto ErrTrap If CurrentView.rpOrdItems.cboProductID.Text = "" Then CurrentView.rpOrdItems.ProductID.SetFocus Else CurrentView.rpOrdItems.cboProductID.SetFocus CurrentWindow.NewRecord End If Goto ExitSub ErrTrap: Msgbox "Error " & Str$(Err) & " - message: " & Error$, 16, "System Error" Resume ExitSub ExitSub: End Sub
If you want to add the new line at the top of the repeating panel, then check out "Inserting a new blank record at the top of a repeating panel" in the <A HREF="examples.htm">Example Databases</A> section of this web site.