Solved

Running a Form From Visual Basic

Posted on 1999-01-24
5
171 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
  • 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

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…
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…

943 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

7 Experts available now in Live!

Get 1:1 Help Now