Solved

vb6 how do you return to a form

Posted on 2009-05-20
7
184 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

829 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