View Single Post
  #8  
Old May 11th, 2010, 05:16 PM posted to microsoft.public.access
John Spencer
external usenet poster
 
Posts: 7,815
Default Stop incomplete details by the user?

If Nz([Inspection By],"") "" And Nz([Channel],"") "" And
Nz([Station],"") "" Then


Should all be on one line. If you copied and pasted from the newsreader it
probably got broken into two lines and therefore is wrong.

Alternative is to use line continuation characters (space underscore) at the
end of the line. Something like:

If Nz([Inspection By],"") "" _
And Nz([Channel],"") "" -
And Nz([Station],"") "" Then
[PrintButtonName].Enabled = True
Else
[PrintButtonName].Enabled = False
End If

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

jo wrote:
hi i do not know code to well and when I put this piece in it is high lighted
in red so I am assuming there is an error with puchuation?
If Nz([Inspection By],"") "" And Nz([Channel],"") "" And
Nz([Station],"") "" Then


"RonaldoOneNil" wrote:

Create a function similar to below and then call it from the after update
event of each of your 3 fields and possibly the On Current event of the form.

Function CheckFields()
If Nz([Inspection By],"") "" And Nz([Channel],"") "" And
Nz([Station],"") "" Then
[PrintButtonName].Enabled = True
Else
[PrintButtonName].Enabled = False
End If
End Function

"jo" wrote:

What if there is more that one field they have missed?
these are the usual fields they miss: [Inspection By] [Channel] [Station]
thanks jo

"RonaldoOneNil" wrote:

Ideally the button should be disabled until all the relevant fields have data
in them but to answer your question
In the click event of your button put something like this

If Nz(Me.[Your Field Name],"") = "" Then
MsgBox "Please enter data into [Your Field Name]", vbInformation +
vbOKOnly, "Incomplete Data"
Me.[Your Field Name].SetFocus
Else
' continue with printing
End If

"jo" wrote:

Is it possible to add code to a form to inform the user that a field has not
been entered once they click the print button? And what would the code be?
please
Thanks Jo