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

checking for data

Status
Not open for further replies.

Zorro1265

Technical User
Nov 14, 2000
181
US
I am using this code to insure that required fields are filled in before my form closes. The check works but now I cant close my form.

If IsNull(Me![Last Name]) Or Me![First Name] Or Me![MRN] Or Me![VisitType] = Chr(32) Then
Response = MsgBox(Msg, Style, Title)
Else
DoCmd.close
End If

Any thoughts?? Zorro
 
How does the check work? It shouldn't. based on what you posted, you cehck to make sure last name is not null and visittype is not chr(32). But what are you doing with the firstname and mrn fields??? there is no evaluation there... Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCSA, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
First of all, you have to assign how you want to evaluate Me![First Name] and Me![MRN]. Right now, only the first and last control in that statement are a complete expression......
 
Yep, you also need to IsNull() First Name and MRN. Right now if there is anything in those fields, it will eval to true and cause the msgbox to popup.
 
Well I thought it was working but you are of course right it only checks the last name. I want to check all four of the above fields and it anyone of them is null I want to get the error message, if they are filled in let the form close. Zorro
 
Ok I tried this but now when I fill in all the required fields I still get my msgbox. Help!

If IsNull(Me![Last Name]) Or IsNull(Me![First Name]) Or IsNull(Me![MRN]) Or IsNull(Me![VisitType]) Then
Response = MsgBox(Msg, Style, Title)
Else
DoCmd.close
End If Zorro
 
Are these bound controls?? If so, insert the following statement before you check for nulls to update the underlying fields:
Code:
Me.Refresh
 
Ok thanks for the input and suggestions I got it to work I forgot that the visit type was on a subform and had to code to look at the sub.

This forum is awesome, the folks here are more help than a dozen textbooks! Zorro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top