G
Garfield
Hello
I have a table called users, and there are 3 types of users, Client,
Counsellors & Volunteers
My switchboard has options to view each type.
I am using same form to display the information of each user type.
I have a combo box which shows the correct users dependant on the user type
selected to display.
However, when the form is first loaded, the combo box is correct,
but the form is showing the 1st record of the table and not of the user type
selected.
Only after I select a value in the combo box will the form synch with the
combo box.
My question is:
How do I get the form to be in synch with the combo when the form is first
opened.
Here is my code so far
Private Sub Form_Load()
Me.cboUserList.RowSourceType = "Table/Query"
Select Case strDisplayUserType
Case "Counsellors"
Me.btnTest.Caption = "Show all Counsellors"
Me.cboUserList.RowSource = "qryAllCounsellors"
Case "Clients"
Me.btnTest.Caption = "Show all Clients"
Me.cboUserList.RowSource = "qryAllClients"
Case "Volunteers"
Me.btnTest.Caption = "Show all Volunteers"
Me.cboUserList.RowSource = "qryAllVolunteers"
Case Else
Me.btnTest.Caption = "Show all Users"
Me.cboUserList.RowSource = "qryAllUsers"
End Select
Forms!Users!cboUserList.Requery 'reloads the combo
box list to reflect the Query
Me!cboUserList = Me!cboUserList.ItemData(0) 'set the first entry in
the combo box
End Sub
Private Sub cboUserList_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[UserID] = " & Str(Nz(Me![cboUserList], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
Thanks
Garfield
I have a table called users, and there are 3 types of users, Client,
Counsellors & Volunteers
My switchboard has options to view each type.
I am using same form to display the information of each user type.
I have a combo box which shows the correct users dependant on the user type
selected to display.
However, when the form is first loaded, the combo box is correct,
but the form is showing the 1st record of the table and not of the user type
selected.
Only after I select a value in the combo box will the form synch with the
combo box.
My question is:
How do I get the form to be in synch with the combo when the form is first
opened.
Here is my code so far
Private Sub Form_Load()
Me.cboUserList.RowSourceType = "Table/Query"
Select Case strDisplayUserType
Case "Counsellors"
Me.btnTest.Caption = "Show all Counsellors"
Me.cboUserList.RowSource = "qryAllCounsellors"
Case "Clients"
Me.btnTest.Caption = "Show all Clients"
Me.cboUserList.RowSource = "qryAllClients"
Case "Volunteers"
Me.btnTest.Caption = "Show all Volunteers"
Me.cboUserList.RowSource = "qryAllVolunteers"
Case Else
Me.btnTest.Caption = "Show all Users"
Me.cboUserList.RowSource = "qryAllUsers"
End Select
Forms!Users!cboUserList.Requery 'reloads the combo
box list to reflect the Query
Me!cboUserList = Me!cboUserList.ItemData(0) 'set the first entry in
the combo box
End Sub
Private Sub cboUserList_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[UserID] = " & Str(Nz(Me![cboUserList], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
Thanks
Garfield