Link to home
Start Free TrialLog in
Avatar of 1030071002
1030071002Flag for United States of America

asked on

vb6 how do you return to a form

The user enters bad data I bring up the messagebox saying bad data please enter the correct data how do I return to the form so that the user can enter the correct data exit sub did not work return did not work how do i do this in vb6
Avatar of Luis Pérez
Luis Pérez
Flag of Spain image

I don't understand. VB6 forms keep staying until you unload them (manually or by code).
I don't understand. VB6 forms keep staying until you unload them (manually or by code).
Show (the code)  how you are bringing up the messagebox when you detect bad data
Avatar of 1030071002

ASKER

Private Sub cmd_save_Click()
Set fso = CreateObject("Scripting.FileSystemObject")
If cmb_doc_type.Text = "" Or IsNull(cmb_doc_type.Text) Then
   MsgBox "Please Select a Document Type", vbCritical, "Error..."
   cmb_doc_type.SetFocus <-- setting focus to the document type
End If
end sub
Avatar of HooKooDooKu
HooKooDooKu

Your code seems to be working for me.
I created a new project, dropped a command button on the form (default name "Command1") and a combo box (default name "Combo1") then paste the following code into the form's code.

I've got VB6 SP6
Private Sub Command1_Click()
    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    If Combo1.Text = "" Or IsNull(Combo1.Text) Then
    MsgBox "Please Select a Document Type", vbCritical, "Error..."
    Combo1.SetFocus
    End If
End Sub

Open in new window

make sure you several combo box check in place and see what happen
Private Sub Command1_Click()
    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    If Combo1.Text = "" Or IsNull(Combo1.Text) Then
    MsgBox "Please Select a Document Type", vbCritical, "Error..."
    Combo1.SetFocus
    End If
   If Combo2.Text = "" Or IsNull(Combo2.Text) Then
    MsgBox "Please Select a Document Type", vbCritical, "Error..."
    Combo2.SetFocus
    End If
   If Combo3.Text = "" Or IsNull(Combo3.Text) Then
    MsgBox "Please Select a Document Type", vbCritical, "Error..."
    Combo3.SetFocus
    End If
End Sub
ASKER CERTIFIED SOLUTION
Avatar of hes
hes
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial