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

Validation

Status
Not open for further replies.

RabSwinney

Technical User
Aug 21, 2002
25
0
0
FI
I have a form with about eleven text boxes, how can I make it mandatory for every box to be filled in, I dont want to do it through the table as there is lots of data already there that is blank. Also I am not up to date in vb
 
Just apply it to the table. Access will let you keep your current empty data.

Otherwise create a macro that cancels the update, shows a message and puts the focus back to the offending box.

 
Hi,
I guess you're looking for some code then. Something like this might help.
Code:
Sub myForm_BeforeUpdate(Cancel As Integer)
Dim ctl as Control
For Each ctl In Me.Controls
    If ctl.ControlType = acTextBox Then
        If IsNull(ctl) Then
            Cancel = True
            ctl.SetFocus
            msgBox ctl.Name & " must be filled in."
            Exit For [green]' only need to find one[/green]
        End If
    End If
Next
End Sub
This saves you writing 11 'If' statements.
HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top