I'm fairly new to VB and just dug out the old disc so sorry if this is in the wrong place or if it's actually a very simple answer..
I'm trying to do an extremely simple login form that doesn't use any other database but i wouldnt mind using a text file, at the moment i'm using this code but it's saying arguement not optional whenever i click the button.
Code:
'Global Variables
Dim Username As String 'Username Variable
Dim Password As String 'Password Variable
Private Sub cmdLogin_Click()
Username = "Test" 'What the Username Variable is
Password = "Test" 'What the Password Variable is
'If Statement Starting Here
'It States that if the username is = to text box and password is = password text box, then it should login, else display error message!
If Username = txtUsername And Password = txtPassword Then
frmLoginSuccess.Show 'Shows the Login Success Form
frmLoginScreen.Hide 'Hides the Login Screen
Else
'A Message box that displays you have entered the wrong username and password
MsgBox ("You have entered the wrong username and password")
End If
End Sub
I think you may have a naming issue or indexing issue as I mentioned. If you dont' find an answer, you may want to zip up your form or project so we can take a look.
Insomnia is just a byproduct of, "It can't be done"
txtUserName and txtPassword are indexed. Their Index property is not blank, it has a number there. So, you must include the index with the control name, i.e.,
txtUserName(0).Text and txtPassword(1).Text.
Optionally, change the Index properties, from the property sheet, for those textboxes to be blank.
Insomnia is just a byproduct of, "It can't be done"
txtUserName and txtPassword are indexed. Their Index property is not blank, it has a number there. So, you must include the index with the control name, i.e.,
txtUserName(0).Text and txtPassword(1).Text.
Optionally, change the Index properties, from the property sheet, for those textboxes to be blank.
Awesome, it's stopped the error.. Just wont do anything when i click the button now?
You need to help us understand better? What exactly do you mean, "won't do anything". The button will either show a message box or display your frmLoginSuccess form, if it exists.
You didn't rename your command button did you? It is still named cmdLogin?
Edited: Cool, you figured it out. Please mark this post as resolved if it is resolved now.
Insomnia is just a byproduct of, "It can't be done"