Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Object Required" error MS Access 97

Status
Not open for further replies.

jjcooll

Technical User
Mar 8, 2001
2
US
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

 
Try:
If IsNull(Me.Serial_Number) Then ..... Gord
ghubbell@total.net
 
Gord,

I haven't tried this yet, but I'm sure it will work just fine.

Thank you very much for ending my overwhelming stupidity. The more I learn about programming, the more I realize I don't know...or the more I forget it seems. I had this problem once before and figured it out, but promptly put it somewhere very hidden inside my head.

Thanks again.

:)

Joel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top