T
Tina
When I changed the code in the first option, I got the
same Type Mismatch error when I clicked the add button....
I think the problem may be that res has not been
declared. How do I declare it and where do I declare
it???? As for the datatype of System_Information it is
text (i.e. AB0040). Does this make a difference and how?
Thank you again for all of your help!!! It is greatly
appreciated!!!
same Type Mismatch error when I clicked the add button....
I think the problem may be that res has not been
declared. How do I declare it and where do I declare
it???? As for the datatype of System_Information it is
text (i.e. AB0040). Does this make a difference and how?
Thank you again for all of your help!!! It is greatly
appreciated!!!
-----Original Message-----
Tina,
The first option gave you a syntax error, because you included part of the
Nz syntax. Use this instead:
res=DMax("System_ID", "[System Information]") +1
For the second option to return a Type Mismatch is strange. Where is res
declared, and what datatype is it?
Graham R Seach
Microsoft Access MCP, MVP
Sydney, Australia
I tried both codes. With the first one, when I pressed on
the add button, the code box opened with the whole line
highlighted and an error message that said "syntax
error". When I tried the second code and clicked the add
button, an error box appeared with the error message Type
Mismatch.
Here's what the codes looked like....Do I have it in the
right spot or am I leaving something out???? Thank you so
much for all of your help!! It is greatly appreciated!!!
----First Option----
Private Sub Add_Record_Click()
On Error GoTo Err_Add_Record_Click
DoCmd.GoToRecord , , acNewRec
res=DMax("System_ID", "[System Information]"),0) +1
Exit_Add_Record_Click:
Exit Sub
Err_Add_Record_Click:
MsgBox Err.Description
Resume Exit_Add_Record_Click
End Sub
----Or second option----
Private Sub Add_Record_Click()
On Error GoTo Err_Add_Record_Click
DoCmd.GoToRecord , , acNewRec
res = Nz(DMax("System_ID", "[System Information]"), 0) +
1
Exit_Add_Record_Click:
Exit Sub
Err_Add_Record_Click:
MsgBox Err.Description
Resume Exit_Add_Record_Click
End Sub
Information]"),0)-----Original Message-----
As Grahan suggested, try
res = DMax("System_ID", "[System Information]") + 1
or even
res = Nz(DMax("System_ID", "[System
+ 1Please indicate what line of the code was causing the problem if that
doesn't solve it.