I'm using a form to add a new record to a table. the table has a autonumber as PK. I have a button that when clicked validate the entry from form fields to table fields. The problem is it would accept to add the new record the first time, I have to click a second time to make it go through. And this because the autonumber had to jump to a new number first.
Can please tell if there is a way to achieve that without having to click twice( just to let you know I'm using this code in the button Sub:
If Not Me.NewRecord Then
RunCommand acCmdRecordsGoToNew
End If
On Error GoTo ErrNew
DoCmd****nCommand acCmdRecordsGoToNew
Exit Sub
ErrNew:
Select Case Err
Case 2046
'Command not available
MsgBox "You cannot add a record at this time.", vbInformation, "Not Available"
Case Else
MsgBox Err.Number & ":-" & vbCrLf & Err.Description
End Select
so the first click always dispalys "You cannot add a record at this time.", message.
Another thing as long the form is open I can perform the adding with no problem(only on click on the button) the problem happens only the first time I open the form
thanks