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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Required Field on close

Status
Not open for further replies.

DaveyEdgar

Technical User
Jul 8, 2002
39
US
Greetings all :)
I found a couple threads for asking a user to fill in a required field on close.

I do understand this can be done easily in the table properties, but like one of the other member's situations, I have two seperate forms based on the same table, and must do this required field on the form level.

Question. Can it be done on an option group?

My close button has this code...
Code:
Private Sub cmddoneadv_Click()
If Me.frmerrvioperf = Null Then
MsgBox "Please choose an Error or Violation"
Else

DoCmd.Close
DoCmd.OpenForm "employees"
DoCmd.Restore
End If

End Sub

"frmerrvioperf" is the name of an option group with two options/radio buttons in it. The problem is, its not working. I click the button when both options are still "greyed out" (null) and nothing happens, the form just closes.
Any help would be greatly appreciated.
 
Anyway, the following will NEVER be true:
If Me.frmerrvioperf = Null Then

Use this instead:
If IsNull(Me.frmerrvioperf) Then

or better this:
If Trim(Me.frmerrvioperf & "") = "" Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Another option would be to use a cancellable event, such as Unload, to check the data validity.

If data is not valid, you can Cancel the event and have the user enter what's needed or dump his work and close the form without saving anything.



The BeforeUpdate event of the form will fire ONLY if the form is bound. You can't use the BeforeUpdate event of the 'offending' control either (for this particular situation), because it can be skipped.

HTH


[pipe]
Daniel Vlas
Systems Consultant

 
Wow thanks guys that did the trick...much obliged :))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top