open form new record

J

jjeca

Hi

What I want is to ask the user for the name is ok open the continuous form,
position on the new record populating the name field and the field of the
last job they did (incremental number) +1.
So far I have this, and there is a bug when I want to create new record

Private Sub Form_Open(Cancel As Integer)

Dim mdp As Variant
mdp = InputBox("Name?")
If mdp <> "SomeName" Then
MsgBox "Not good"
Cancel = True
Else
DoCmd.GoToRecord , , acNewRec <= it says there is a bug here!?
Me.[job] = Nz(DMax("[job]", "tab_minute", "[name] = 'SomeName'") + 1)
Me.[name] = "SomeName"
End If

End Sub

Thanks in advance
 
Top