Please help,
I am a relatively new Access programmer. Here's my problem.
I have a form. This form has a custom "save" button. I have written code for the button-click sub which should validate whether data has been enterred in a specific field. If field is "null", a message box should pop up, telling the user to enter the required data. Instead, I keep getting the error message, "Object Required", as soon as I click the save button. Following is my code.
Dim intsaverecrd As Integer, strtitle As String
Dim intmsgdialog As Integer, strmsg As String
If Me.Serial_Number Is Null Then
msgbox ("You must supply a Barcode or a Serial Number. If you cannot, please click the 'Undo' button after exiting this dialogue box."
Else
'Display message box asking if user wants to Cancel adding a new user
strtitle = "Save Changes"
strmsg = "Are you sure you would like to Save all Hardware changes?"
intmsgdialog = vbYesNo + vbExclamation
intsaverecrd = msgbox(strmsg, intmsgdialog, strtitle)
If intsaverecrd = vbYes Then
'Save record, Go to first record, reset allowadditions to false, and return to main User Hardware Form
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.AllowAdditions = False
Me.AllowEdits = False
DoCmd.Save
Me.Requery
Call Form_Current
Else
DoCmd.CancelEvent
End If
End If
The three lines (in bold) after my variable declaration are the lines giving me trouble. The rest worked fine before I tried to make this change.
Any help would be appreciate. Even just a description of the cryptic "Object Required" error message would be nice.
Thanks for your help!
JJCooll
I am a relatively new Access programmer. Here's my problem.
I have a form. This form has a custom "save" button. I have written code for the button-click sub which should validate whether data has been enterred in a specific field. If field is "null", a message box should pop up, telling the user to enter the required data. Instead, I keep getting the error message, "Object Required", as soon as I click the save button. Following is my code.
Dim intsaverecrd As Integer, strtitle As String
Dim intmsgdialog As Integer, strmsg As String
If Me.Serial_Number Is Null Then
msgbox ("You must supply a Barcode or a Serial Number. If you cannot, please click the 'Undo' button after exiting this dialogue box."
Else
'Display message box asking if user wants to Cancel adding a new user
strtitle = "Save Changes"
strmsg = "Are you sure you would like to Save all Hardware changes?"
intmsgdialog = vbYesNo + vbExclamation
intsaverecrd = msgbox(strmsg, intmsgdialog, strtitle)
If intsaverecrd = vbYes Then
'Save record, Go to first record, reset allowadditions to false, and return to main User Hardware Form
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.AllowAdditions = False
Me.AllowEdits = False
DoCmd.Save
Me.Requery
Call Form_Current
Else
DoCmd.CancelEvent
End If
End If
The three lines (in bold) after my variable declaration are the lines giving me trouble. The rest worked fine before I tried to make this change.
Any help would be appreciate. Even just a description of the cryptic "Object Required" error message would be nice.
Thanks for your help!
JJCooll