Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

vb6 how do you return to a form

Posted on 2009-05-20
7
Medium Priority
?
189 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 500 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

722 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