Second Click to Add Record shows first subform record

M

mma40

I have a button on Main form that allows me to add records to the
subform via an entry form. When I save that entry, I return to the
form and it adds the new data. If I need to add another subform record
or delete a subform record and then click the Add button, I get the
information for the first subform record instead of a new dataentry
form. I have tried many different things but nothing works. Any help is
appreciated. Below is the code for the button

Private Sub VisitEntry_Click()
'New variable
Dim fContinue As Boolean

On Error GoTo Err_VisitEntry_Click
'Start with fContinue true then mark it
'false whenever a field needs to be fixed
fContinue = True
'Only check existing records
If Not Me.NewRecord Then
If IsNull(Me.County) Then
MsgBox "County must be entered"
Me.County.SetFocus
fContinue = False
ElseIf IsNull(Me.EthnicGroup) Then
MsgBox "Ethnic Group must be entered"
Me.EthnicGroup.SetFocus
fContinue = False
ElseIf DMax("VisitDate", "UserDates", "UserNumber = " &
Nz([UserNumber], 0)) = Date Then
MsgBox "Today's Visit Already Exits"
fContinue = False
End If
End If

If fContinue Then
DoCmd.OpenForm "VisitEntry", acFormAdd, , "[UserNumber]=" &
Me![UserNumber]
End If

Exit_VisitEntry_Click:
Exit Sub

Err_VisitEntry_Click:
MsgBox Err.Description
Resume Exit_VisitEntry_Click

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top