Add command button to update subform

rsbutterfly16

Registered User.
Local time
Today, 01:17
Joined
Jun 5, 2006
Messages
77
hi guys i have a main form with a subform. i have created an add command button to add rows in the subform. (it could only add when the record count is less than 3). here is my code

If Me.SubFormName.Form.RecordsetClone.RecordCount >= 3 then
Msgbox " You can only add three"
cancel=true ' cancel event
me.SubFormName.Form.FieldName.SetFocus ' Set the focus to the field
exit sub
End if

i get no errors, However my problem is that it puts the focus on the begginning of the subform, i wanted to go to the end of the subform or new row... right now i have to go mannually until the last row... is there anyway to put the focus on the last row?

:rolleyes:
 
How bout adding....... DoCmd.GoToRecord , , acLast
 
thanks but it goes to the last record of the main form instead of the subform... :confused:
 
Code:
If Me.SubFormName.Form.RecordsetClone.RecordCount >= 3 then
    Msgbox " You can only add three"
    Cancel=True ' cancel event
Else
    Me.SubFormName.SetFocus
    DoCmd.GoToRecord , , acNewRec
    DoCmd.GoToControl "NameofControl"
Exit sub

End if
 

Users who are viewing this thread

Back
Top Bottom