Here is some of the code...hopefully the parts that will help you understand
what I'm doing.
=============
'THERE IS A 'CLICK' EVENT FOR EACH cmdBUTTON - THEY ARE IDENTICAL EXCEPT FOR
THE SUB NAME AND THE FORM EACH OPENS
Private Sub cmdLoginAaron_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 list box
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
DoCmd.OpenForm "frmAaron"
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
===============================
'TEXT24 IS A TEXT BOX THAT LOOKS UP THE EMPID IN A TABLE - THIS EQUALS THE
CASE NUMBER FOR EACH LOGON
Private Sub List31_Click()
Dim Code
Code = Me!Text24
Select Case Code
Case 11 'Aaron
Me!cmdLoginFull.Visible = False
Me!cmdLoginManagement.Visible = False
Me!cmdLoginOffice1.Visible = False
Me!cmdLoginOffice2.Visible = False
Me!cmdLoginForeman.Visible = False
Me!cmdLoginGeneral.Visible = False
Me!cmdLoginAdmin.Visible = False
Me!cmdLoginMaterialControl.Visible = False
Me!cmdLoginShop.Visible = False
Me!cmdLoginQuality.Visible = False
Me!cmdLoginAaron.Visible = True
Case Else 'No Criteria
Me!cmdLoginFull.Visible = True
Me!cmdLoginManagement.Visible = False
Me!cmdLoginOffice1.Visible = False
Me!cmdLoginOffice2.Visible = False
Me!cmdLoginForeman.Visible = False
Me!cmdLoginGeneral.Visible = False
Me!cmdLoginAdmin.Visible = False
Me!cmdLoginMaterialControl.Visible = False
Me!cmdLoginShop.Visible = False
Me!cmdLoginQuality.Visible = False
Me!cmdLoginAaron.Visible = False
End Select
[txtPassword].SetFocus
End Sub
============
"e.mel" wrote:
> Null can give seemingly unusual reselts sometimes.
> how are you using text24, maybe putting Nz() around it will help - this
> will convert Null to "".
>
> also a control cant be made invisible if it has the focus
>
> but I doubt either of these is the problem. Can you post the code
> where get to the various case numbers. ie how does text24=Null lead
> to Case 12
>
>
>
> neenmarie wrote:
> > I changed it to Case Else - with the same results. The two buttons are still
> > visible until the user selects a name from the combo box. Then they
> > disappear and the button corresponding to the selected name becomes visible.
> > The buttons are spelled correctly. I also have tried to add additional test
> > buttons and they too stay visible until a name is selected. So the "visible
> > - false" is working in the other Cases. But for some reason, not in the NULL
> > case. Any additional ideas?
> >
> > "Ofer Cohen" wrote:
> >
> > > What happen if you write istead of Case 12 ,
> > > Try
> > > Case Else
> > >
> > > That will enter this code if no other case number is applied
> > >
> > > --
> > > Good Luck
> > > BS"D
> > >
> > >
> > > "neenmarie" wrote:
> > >
> > > > I have a list box that when clicked fills a number in a text box (text24)
> > > >
> > > > I then have code that looks at this text box number to determine which case
> > > > to use and then shows a command button that corresponds with the case. All
> > > > command buttons should not be visible until the corresponding case is
> > > > selected.
> > > >
> > > > The last case is when the text box is empty. Then no command buttons should
> > > > show on the form. This is all working perfectly except for two buttons.
> > > > When the Text box is null, they still show up. They do disappear when
> > > > something is selected from the list box that corresponds to a case where they
> > > > should not be visible. I've copied and pasted from other cases to be sure I
> > > > don't have a typo. But, these last two buttons still show up when text24 is
> > > > empty. (cmdLoginAdmin and cmdLoginAaron) Here is the code for the last case:
> > > >
> > > > Case 12 'No Criteria
> > > >
> > > > Me!cmdLoginFull.Visible = False
> > > > Me!cmdLoginManagement.Visible = False
> > > > Me!cmdLoginOffice1.Visible = False
> > > > Me!cmdLoginOffice2.Visible = False
> > > > Me!cmdLoginForeman.Visible = False
> > > > Me!cmdLoginGeneral.Visible = False
> > > > Me!cmdLoginAdmin.Visible = False
> > > > Me!cmdLoginMaterialControl.Visible = False
> > > > Me!cmdLoginShop.Visible = False
> > > > Me!cmdLoginQuality.Visible = False
> > > > Me!cmdLoginAaron.Visible = False
>
>
|