I appreciate your time.
Yes, the message box worked. It recognized and displayed the data in
text60
on the form.
What I'm trying to accomplish is to have only one button that will open
differnt forms depending on the name found in text60. That way I won't
end
up with fifty buttons on the form. Text60 uses DLookup to find the name
of
the form corresponding to the employee name selected from a listbox on the
form.
Below is the current entire code for the button to open the form.
Private Sub Command62_Click()
'Check to see if data is entered into the UserName list box
If IsNull(Me.Text24) Or Me.Text24 = "" Then
MsgBox "You must choose a User Name.", vbOKOnly, "Required Data"
Me.Text24.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Valid Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
'If Me.txtPassword.Value = DLookup("EmpPassword", "tblEmployees",
"[EmpID]="
& Me.Text24.Value & " And [EmpName]='" & Me.Text34.Value & "'") Then
'lngMyEmpID = Me.Text24.Value
If Me.txtPassword.Value = DLookup("EmpPassword", "tblEmployees",
"[EmpID]="
& Me.Text24.Value & " And [EmpName]='" & Me.Text34.Value & "'") Then
lngMyEmpID = Me.Text24.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "frmLogon", acSaveNo
'THE NEXT LINE OF CODE IS WHERE I'D LIKE TO REFER TO TEXT60 INSTEAD OF
CODING IN A SPECIFIC FORM NAME
DoCmd.OpenForm "frmClyde"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.",
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Jeff Boyce said:
If I take the error message literally (always an iffy prospect with
Access
error messages!), Access is telling you that it doesn't have a form named
[text60].
You already have code to open the form. Add the following line of code
just
before the OpenForm command...
MsgBox "text60 = " & Me!text60
If you have a control named "text60" on your form, and if the code you
provided is running in that form, the the message box will pop up,
showing
you what is in the control named "text60".
How are you putting the name of the form into that control?
Regards
Jeff Boyce
Microsoft Office/Access MVP
I don't know how to write the code to recognize the value in in the text
box
"text60" to open the form named there or to display it in a msgbox.
The error message I'm getting with: DoCmd.OpenForm text60
Runtime error '2102'
The form name 'text60' is misspelled or refers to a form that doesn't
exist.
I also tried text60.value and got an error also.
:
Doesn't work ...
Do you mean "nothing happens"?
Do you mean "I get an error message"? (if so, tell us -- it's hard to
diagnose without it)
Do you mean "my PC turns into a pumpkin and explodes"?
One thing you could try would be to add a MsgBox() command just before
the
DoCmd.OpenForm text60 command. In the msgbox, have it display the
value
that is in text60. This way, you'd know if the OpenForm command is
receiving anything to open.
Regards
Jeff Boyce
Microsoft Office/Access MVP
I have a form being used as a menu. I'd like a command button to
open
which
ever form is listed in a text box. The text box is not visible and
is
populated once the user clicks an employee's name in a list box.
the
DLookup
function is then used to find the form (menu) corresponding to that
employee.
Instead of:
DoCmd.OpenForm "frmAaron"
I'd like something like:
DoCmd.OpenForm text60
Unfortuantely, that doesn't work.
Can anyone help me?