Solved

vb6 how do you return to a form

Posted on 2009-05-20
7
175 Views
Last Modified: 2012-05-07
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
0
Comment
Question by:1030071002
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 25

Expert Comment

by:Luis Pérez
ID: 24433148
I don't understand. VB6 forms keep staying until you unload them (manually or by code).
0
 
LVL 25

Expert Comment

by:Luis Pérez
ID: 24433151
I don't understand. VB6 forms keep staying until you unload them (manually or by code).
0
 
LVL 20

Expert Comment

by:hes
ID: 24433174
Show (the code)  how you are bringing up the messagebox when you detect bad data
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:1030071002
ID: 24433289
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
0
 
LVL 16

Expert Comment

by:HooKooDooKu
ID: 24433516
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

0
 

Author Comment

by:1030071002
ID: 24433745
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
0
 
LVL 20

Accepted Solution

by:
hes earned 125 total points
ID: 24434066
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
Exit Sub
    End If
   If Combo2.Text = "" Or IsNull(Combo2.Text) Then
    MsgBox "Please Select a Document Type", vbCritical, "Error..."
    Combo2.SetFocus
Exit Sub
    End If
   If Combo3.Text = "" Or IsNull(Combo3.Text) Then
    MsgBox "Please Select a Document Type", vbCritical, "Error..."
    Combo3.SetFocus
Exit Sub
    End If
' Now do whatever you want to do if data is good
End Sub
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Use closed file on desktop in vba 6 65
Vb.net 2008 2 56
VB error "Type mismatch" 2 49
passing parameter in sql procedure 9 56
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now