set method question

mech55

Registered User.
Local time
Today, 13:20
Joined
Aug 26, 2005
Messages
61
I need to set my part number to stay in the text box if this IF statement is true. Anyone know what property I need to use?


Private Sub PartNumber_LostFocus()
If (PartNumber = "") Then
MsgBox ("YOU MUST ENTER A PART NUMBER!")
PartNumber.
End If
End Sub
 
Why not just set it to 'required' at the table level?
 
I sure did, and i'm not sure what the problem is but for some reason it's not askign for it, and it's even the Primary key!
 
The runtime error will not be triggered until the forms BeforeUpdate event if the field is tagged as Required in the table.

Also, check for Nulls as well as empty strings.

Code:
If IsNull(PartNumber) or PartNumber = "" Then
All verification code should be placed in the forms BeforeUpdate event.

Check out these two links for working examples on how to do it...

A better mouse trap? Another twist on how to prevent a modifed record from being saved unless the user clicks a custom Save button.

Enable/Disable The Control Box X Button The form named "fTestCancelFromUnloadEvent" in the Enable/Disable The Control Box X Button sample db will demonstrate how you can prevent a user from closing a form and also the application unless they do exactly what you want them to do.
 

Users who are viewing this thread

Back
Top Bottom