Variable not defined

basilyos

Registered User.
Local time
Today, 04:29
Joined
Jan 13, 2014
Messages
256
hello there

this is my code

Code:
Private Sub cmdSave_Click()
If DCount("P_ID", "tbl_Edbarat_Sanctions_1", "[P_ID] = " & [P_ID]) > 0 Then
'no need to enter the record because it's existed
Else
'we should enter the record because it's not existed
strsql101 = "insert into tbl_Edbarat_Sanctions_1 (P_ID, Memo_Notation_Serial_Number) Values ('" & Me.P_ID & "', '" & Me.txtSerialNumber & "')"
DoCmd.RunSQL strsql101
End If
End Sub
when i press the button i got an error message (Compile error: variable not defined)

any help?
 
Use the debugger to determine which variable is not defined.
 
that one is highlighted

strsql101 =


i did anything else as they mentioned in the first post i check the variable declaration

when i closed the database and reopen it i got this message
compile error in hidden module: Form_frm_Personal_Information_01.
this error commonly occurs when code in incompatible with the version, platform, or acrhitecture of this application.

btw i used the same code in other form with some addition of fields in another table

any help????
 
Last edited:
that one is highlighted

strsql101 =


i did anything else as they mentioned in the first post i check the variable declaration

when i closed the database and reopen it i got this message
compile error in hidden module: Form_frm_Personal_Information_01.
this error commonly occurs when code in incompatible with the version, platform, or acrhitecture of this application.

btw i used the same code in other form with some addition of fields in another table

any help????

If you haven't already declared it as module or global level then it needs to be declared within the function.

If you think you've declared it globally (not preferable in this case) or at the module level (also not preferable in this case) there maybe a miss-spelling. Dim it within the function and it will work.

Steve.
 

Users who are viewing this thread

Back
Top Bottom