Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple question

Status
Not open for further replies.

mama16

MIS
Oct 22, 2004
125
US
I created this form for security purposes, and on the button ( Enter ) I
did this


Private Sub cmd3_Click()
On Error GoTo Err_cmd3_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim txtPasword As String


txtPassword = "7389"
stDocName = "Switchboard"

If txtPassword = "7389" Then
DoCmd.OpenForm stDocName, , , stLinkCriteria

Else
MsgBox "Can't log on. Username and password do not match. "

End If

Exit_cmd3_Click:
Exit Sub

Err_cmd3_Click:
MsgBox Err.Description
Resume Exit_cmd3_Click

End Sub

It's not working, why?
I just started learning VB, any ideas?
 
Are you getting an error? If so on which line?

If you are not getting an error or the event is not firing then you can check if the macro is associated with the button.
Right click on the button. Select properties.
Go to the events tab.
In the on click event see if it says [event procedure] (it should). If not click the ellipsis to the right of On Click and select code builder. Place the code between the Sub and End Sub that is provided.

Another thing to check is if your button's name is cmd3.

HTH,
Eric
 
I've checked that and its OK. When I enter anything in the text box, it immediately opens up the switchboard form. It's not giving me an error if I type anything else besides 7389
 
How are ya mama16 . . . . .

Nothing assigned to [purple]stLinkCriteria![/purple]

Calvin.gif
See Ya! . . . . . .
 
Ok. You are setting the password in your code. Change this line of your code:

txtPassword="7389"

to

txtPassword=me.YourTextBoxName

Change "YourTextBoxName" to the name of your password textbox.

HTH,
Eric
 
It worked,

Why this txtPassword=me.YourTextBoxName and not this

txtPassword="7389"?
It looks like a simple thing but damn I was having a hard time.

Thanks guys

I'm doing good Aceman, thanks for asking.
Does anybody knows a book on VB and Access that's any good?

 
Yo Mama!

I think you have to refer to txtPassword something like this (I am also not so good at VBA):
[forms]![yourform]![textpassword]

"Me." is a shortcut for "[forms]![yourform]!" if the field you are refering to is on the current form.

Henry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top