![]() The "MsgBox" statement will load a pop up box if the Login is not successful. The "Exit Sub" line will terminate the rest of the code if the LoginFlag is set to true, the two "End If" statements will tell Excel to stop checking the relevant IF statements set earlier. The "Unload Me" statement makes sure the form closes on a successful login. Below the LoginFlag line, write: Unload Me Exit Sub End If End If MsgBox "Sorry, Incorrect Login Details" ![]() Now we need to tell Excel to stop checking for the values and what to do if they are not the correct values. This will set a Login flag that we can check against when opening sheets. You should write underneath: LoginFlag = True Now we need to tell VBA what to do if that is the case. ![]() The two lines together will check that all Login information is correct. This line tells Excel to check that the value in the textbox called "Password" is equal to "1234". You can now resize the entire Userform to fit the items placed on it like in the example.Change the name of the command button from "CommandButton1" to "LoginButton" and the caption to "Login". From the toolbox, click on the Command Button icon (looks like a grey rectangle) and draw a button below the password field.Place a "*" in this field, this means that characters typed are hidden, like a standard password field. With the "Password" Textbox selected, find the " PasswordChar" property from the Properties window.The Command Buttons 'Add Record' and 'Other Stuff' have no Code as yet. Repeat steps 2 - 6 for the "Password" field and label ensuring the Textbox is named "Password". Re: HELP: Inserting a drop down box into a Data Entry Form.This name is used to reference the Textbox in the code we'll write later. With the new Textbox selected, edit the " Name" field to "Username".From the toolbox, select the "AB|" button and place a Textbox underneath the "Username" label.Resize the label to fit the text, otherwise it can overlap other items.You can do this by either clicking once, waiting 2 seconds and then clicking again (Double clicking will take you to the code screen for that label) or editing the Caption in the Properties window. You'll need to edit the label to read "Username". ![]() From the toolbox, select the "A" button and place a label in the top left corner of the UserForm.Notice that the UserForm title still says "Userform1"? You'll also need to edit the " Caption" field to something like "Please Login".In the Properties window (bottom left) you'll see " Name" field, change this to "Login". ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |