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!

Showing another form once data is validated

Status
Not open for further replies.

hawaiian1975

Programmer
Nov 7, 2003
26
US
I am trying to show pass data to another form once the data is validated. My problem is that when I click the next form selection, it will validate the data and still move on to the next form. For example, I type in 23A6, it will validate the data as invalid and still move on to the next form. Here is the code that I am trying:

Private Sub mnuDataNextForm_Click()
Const conBtns = vbOK + vbExclamation + vbDefaultButton1 + vbApplicationModal

Dim Ndx As Integer
Dim Cancel As Boolean

For Ndx = txtWheel.LBound To txtWheel.UBound
txtWheel_Validate Ndx, Cancel
If Cancel Then
MsgBox "Invalid Data", conBtns, "Data Entry Form"
txtWheel(Ndx).SetFocus
Else
frmCompute.Show
frmDataEntry.Hide
Exit For
End If
Next Ndx

End Sub
 
I can't see what luisfelipe007's suggestion was, but it looks to me as though you've got the 'Exit For' in the wrong place.

If you put it after the failed validation message (instead of after showing the next form) then the program can continue and the Setfocus will work. Otherwise it will keep validating items and if it finds a valid one, it will display the next form and then exit the loop.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top