Close form command button

L

Lori

Hi,

I pasted the following code into the "on click" event of my close form
command button and added my field name. When I run it, it stops at "Chr(13)"
and gives me the error "Compile Error -Can't find project or library". I am
new to access, please tell me what this is, do I need to change this also?

If IsNull(Me![ContactCompanyID]) Then
If MsgBox("'ContactCompanyID' must contain a value." & Chr(13) & Chr(10) & _
"Press 'OK' to return and enter a value." & Chr(13) & Chr(10) & _
"Press 'Cancel' to abort the record.", _
vbOKCancel, "A Required field is Null") = vbCancel Then
DoCmd.Close
Else
Me![ContactCompanyID].SetFocus
End If
Else
DoCmd.Close
End If
 
D

Douglas J Steele

Your References collection may have gotten corrupted.

While in the VB Editor (and with no code running), select Tools |
References, and look at the selected references. If any of them have
"MISSING:" in front of them, unselect them and back out of the dialog. (You
should write down the names of the ones you deleted) Compile your
application (under the Debug menu). If it compiles cleanly, you likely
weren't actually using the missing references. If it doesn't, go back into
the References dialog and scroll through the list of available references
until you find the ones you unchecked and recheck them.
 
L

Lori

I had two "Missing", after unchecking...it ran great. Thanks so much, you
are very smart.
--
Thank, Lori


Douglas J Steele said:
Your References collection may have gotten corrupted.

While in the VB Editor (and with no code running), select Tools |
References, and look at the selected references. If any of them have
"MISSING:" in front of them, unselect them and back out of the dialog. (You
should write down the names of the ones you deleted) Compile your
application (under the Debug menu). If it compiles cleanly, you likely
weren't actually using the missing references. If it doesn't, go back into
the References dialog and scroll through the list of available references
until you find the ones you unchecked and recheck them.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Lori said:
Hi,

I pasted the following code into the "on click" event of my close form
command button and added my field name. When I run it, it stops at "Chr(13)"
and gives me the error "Compile Error -Can't find project or library". I am
new to access, please tell me what this is, do I need to change this also?

If IsNull(Me![ContactCompanyID]) Then
If MsgBox("'ContactCompanyID' must contain a value." & Chr(13) & Chr(10) & _
"Press 'OK' to return and enter a value." & Chr(13) & Chr(10) & _
"Press 'Cancel' to abort the record.", _
vbOKCancel, "A Required field is Null") = vbCancel Then
DoCmd.Close
Else
Me![ContactCompanyID].SetFocus
End If
Else
DoCmd.Close
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top