Solved

vb6 how do you return to a form

Posted on 2009-05-20
7
172 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
Comment Utility
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
Comment Utility
I don't understand. VB6 forms keep staying until you unload them (manually or by code).
0
 
LVL 20

Expert Comment

by:hes
Comment Utility
Show (the code)  how you are bringing up the messagebox when you detect bad data
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:1030071002
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 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

6 Experts available now in Live!

Get 1:1 Help Now