Open Filtered Form thru Logon Form

  • Thread starter mabedin via AccessMonster.com
  • Start date
M

mabedin via AccessMonster.com

Hi,

I have seen serveral filtered form and logon form. I have the same problem as
well. I am trying ot filter a Contact form when a user logon on to the form.

I have accomplished the logon part. But I am unable to filter the
"frmContact" Form.

frmLogon
--------------
cboEmployee (combo box) - this drop downs Agent's First Name and Last Name in
text format
txtPassword (textbox)
Go button

Once the password and user id is correct and verified, I have coded

DoCmd.OpenForm "Contacts"

frmContact
----------------

frmContact On Open Property code is:

Private Sub Form_Open(Cancel As Integer)

If Form_frmLogon!cboEmployee = "FirstName LastName" Then

' *************************************************
' I can use
' If Form_frmLogon!cboEmployee = 13 Then
' 13 is the EmployeeID
' *************************************************
Form.FilterOn = False
AgentID.Enabled = True
AgentID.Locked = False
AgentID.Visible = True
cboLeadStatusID.Visible = True
cmdImportLeads.Visible = True
cmdAddViewAgentsInformation.Visible = True

Else
Form.FilterOn = True
AgentID.Enabled = False
AgentID.Locked = True
AgentID.Visible = True
Notes.Enabled = False
Notes.Locked = True
'Notes.BackStyle = Transparent
cmdViewReports.Visible = False
Label50.Visible = False

End If
End Sub


Please help. Thanks in advance.
 
S

Svetlana

Try to put the code that you have on open event on your frmContact form
to frmLogon form as like

DoCmd.OpenForm "frmContacts"
Forms!frmContact.Filter = "EmployeeID=" & Me!cboEmployee
Forms!frmContact.FilterOn=True
Forms!frmContact!AgentID.Enabled = True
Forms!frmContact!AgentID.Locked = False
Forms!frmContact!AgentID.Visible = True
Forms!frmContact!cboLeadStatusID.Visible = True
Forms!frmContact!cmdImportLeads.Visible = True
Forms!frmContact!cmdAddViewAgentsInformation.Visible = True
 
Top