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 form's controls for valid data 2

Status
Not open for further replies.

jean2002

Technical User
May 1, 2003
75
DE
Good morning!

I have a form which an user fills in, and before clicking on a button to go to the next form, there must be a check that all controls have been filled in completely.

For example, if I have frm1 with fraOne, cboOne & txtOne, I wrote the following code for the OnClick event for cmdNext:

Code:
Private Sub cmdNext_Click()
  
Completeness_Check:
  If IsNull(cboOne) Or IsNull(fraOne) Or IsNull(txtOne) Then
    MsgBox ("An answer is missing")
    Resume Completeness_Check
  End If
    
  DoCmd.OpenForm "frm2", acNormal
  
End Sub

I then get a runtime error "Resume without error". I suspect that I am using the Resume statement incorrectly in this case. Please can someone suggest a solution to solving this?

Thanks,
Jean
 
Something like this ?
Private Sub cmdNext_Click()
If IsNull(cboOne) Or IsNull(fraOne) Or IsNull(txtOne) Then
MsgBox ("An answer is missing")
cboOne.SetFocus
Else
DoCmd.OpenForm "frm2", acNormal
End If
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Or

assuming you want to trap, nulls OR spaces

Private Sub cmdNext_Click()
If Len(Trim(Nz(cboOne,"")&"")) = 0 Or Len(Trim(Nz(fraOne,"")&"")) = 0 Or Len(Trim(Nz(txtOne,"")& "")) = 0 Then
MsgBox ("An answer is missing")
cboOne.SetFocus
Else
DoCmd.OpenForm "frm2", acNormal
End If
End Sub

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanks,

with using some if...elseif...else statements i got my version to work!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top