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

tabb change event 1

Status
Not open for further replies.
Feb 4, 2009
137
US
Hello, please help...thanks.
I have an access form with a tab has 6 pages. Each page has several required fields need to fill in before moving to the next tab. So I would like to do some message box pop up when users haven't filled it in all required fields when clicking on the next tab...but I don't know how to do it...Please help.
Thanks...I'm very appreciated.
 
Does each page have their own subform ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
So, use the BeforeUpdate event procedure of the form to enforce all the rules, playing with the Cancel parameter and the SetFocus method.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I tried the code below but nothing work or even get an error on that...

Private Sub Form_BeforeUpdate(Cancel As Integer)
'This throws the error and still switches tabs
'Enforce required fields on a form
Dim ctl As Control
For Each ctl In Me

If ctl.Tag = "Required" Then
If IsNull(ctl) Or ctl = "" Then

Cancel = True
MsgBox "You must complete all required fields to continue", vbCritical, "Required Field"
ctl.SetFocus
Exit Sub
End If
End If
Next
'All fields are validated, now set ctl to essentially being unbound

Set ctl = Nothing


End Sub
 
Have you tried to debug step by step (F8) your code ?
BTW, all required controls have Required (no quote) in their Tag property ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry, hit Submit too fast.

Anyway, I'd replace this:
If IsNull(ctl) Or ctl = "" Then
with this:
If Trim(ctl & "") = "" Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top