Solved

Running a Form From Visual Basic

Posted on 1999-01-24
5
175 Views
Last Modified: 2013-11-25
I have a program with two forms in it. The first form will ask for a password. The second form will be the actual program. How do I get the second form (actual program) to run after someone clicks the OK button on the password form. Form2.Show doesn't seem to work. (duh) Make this easy on me as I'm just another lame-o in the crowd.
Thanks
0
Comment
Question by:bendown
[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
5 Comments
 
LVL 1

Accepted Solution

by:
chualk earned 50 total points
ID: 1470451
Just code in the first form
Private function cmdOk_click()
           if text1.text = password then
             form2.show
          else
            msgbox "Invalid password.Try again!"
            text1.setfocus
          end if
end function

0
 

Author Comment

by:bendown
ID: 1470452
Chaulk,
   The code that you suggested is what i have now. It will not run the form though. Here is the code that I have now:
Private Sub cmdOK_Click()
 Dim OldPswd As String
   Dim FName As String
   Dim DefaultPassword
   Dim Msg, Style, Title, Help, Ctxt, Response, MyString
   FName = "c:\windows\pass.pas"
   Open FName For Input As #1   ' Open file.
   Line Input #1, OldPswd
   Close #1

   If txtPassword.Text = OldPswd Then
        OK = True
        Form1.Show
End
       
    Else
       
       MsgBox "Please Enter Correct Password"
        txtPassword.SetFocus
        txtPassword.SelStart = 0
        txtPassword.SelLength = Len(txtPassword.Text)
       
    End If

End Sub

Note: Form2 is my password form. Form1 is the Actual Program.
Please submit any ideas on this to me.
Thanks
0
 

Expert Comment

by:girsu
ID: 1470453
if the END statment after Form1.Show is in your code, you have to remove it, you can use UNLOAD ME to hid the logon form.
0
 

Expert Comment

by:girsu
ID: 1470454
if the END statment after Form1.Show is in your code not dragged by mistake, you have to remove it, you can use UNLOAD ME to hid the logon form.
0
 

Author Comment

by:bendown
ID: 1470455
That did the trick. I did leave out unload me. Girsu, you caught my mistake and Chualk, you had the right idea too. I will give Chualk the points. I will also give Girsu points.
Girsu, Look for:"This Points To Girsu ONLY"
Thanks Again
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Trouble with References... 5 67
Problem to With line 4 86
Macro problems with Excel file 6 52
RestClient.cs fails at (HttpWebResponse)request.GetResponse()) 4 50
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

737 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