I have a form where users put their name/password to open another form. After putting the password the users click a button I created to open the other form.
My question is this: I want the users to be able to open the other form by pressing Enter as well as clicking on the button.
How can I do this?
Here's the code behind the button I created. How can I add to this code so users can press enter to open the form if they like?
Private Sub Command4_Click()
On Error GoTo Err_Command4_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim conDB As ADODB.Connection
Dim rsSalesReps As ADODB.Recordset
Dim strSalesRepPwd As String
Set conDB = New ADODB.Connection
conDB.Provider = "Microsoft.Jet.OLEDB.4.0"
conDB.Open "\\backup\departments\mrkt\Contact_Management_Data base\Contact_Management_Database.mdb", "Admin", ""
Set rsSalesReps = New ADODB.Recordset
rsSalesReps.Open "select SalesRepPwd from SalesReps where SalesRepID=" & Me![Combo0], conDB
strSalesRepPwd = Trim(rsSalesReps!SalesRepPwd & "")
Set rsSalesReps = Nothing
Set conDB = Nothing
If strSalesRepPwd = Trim(Text2.Text & "") Then
stDocName = "Contacts"
If Me![Combo0] <> 1 Then '1 = Admin
stLinkCriteria = "[SalesRep]=" & Me![Combo0]
DoCmd.OpenForm stDocName, , , stLinkCriteria
in the Properties of that text Feild build a Event Base on the Key Press
Private Sub Address_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
'has press enter
hope this help
See clear as mud
the aim is store once, not store multiple times
Remember... Optimize 'til you die!
Progaming environment: Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010 VB based on my own environment: vb6 sp5 ASP based on my own environment: 5.6 VB-NET based on my own environment started 2007 SQL-2005 based on my own environment started 2008 MYLE YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.
Supposing the name for your password textbox is myPasswordTextBoxName. Your KeyDown event for the TextBox should look like.....
Private Sub myPasswordTextBoxName_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then 'vbKeyReturn is a global Constant for the Enter key.
KeyCode = 0