Solved

Running a Form From Visual Basic

Posted on 1999-01-24
5
170 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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 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…

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