Hiding button

  • Thread starter Thread starter Bill Neilsen
  • Start date Start date
B

Bill Neilsen

I have a form with multiple fields and a button which prints a report of the
current record.

I'm having all sorts of difficulties ensuring that all fields are completed
before the report is printed.

Is it possible to hide the button untill all fields are completed?

If so, can anyone show me the code please?
 
1. Open your table in design view. For each field where the user *must*
enter something, set its Required property (lower pane in table design) to
Yes. Now they won't be able to save the record until they fill those fields
in.

2. For the fields where you want to provide a warning, use the BeforeUpdate
event of the *form* to test if your fields are null. Example:

Private Sub Form_BeforeUpate(Cancel As Integer)
Dim strMsg As String
If IsNull(Me.Surname) Then
strMsg = strMsg & "Surname is blank" & vbCrLf
End If
If IsNull(Me.City) Then
strMsg = strMsg & "City is blank" & vbCrLf
End If
'etc for other fields.
If strMsg <> vbNullString Then
strMsg = strMsg & vbCrLf & "Proceed anyway?"
If MsgBox(strMsg, vbYesNo+vbDefaultButton2) <> vbYes Then
Cancel = True
End If
End If
End Sub
 
Back
Top