R
Rey
Howdy all.
My search form has a list box displaying the results of a wild card
search for first or last name or pet name.
When listbox is clicked, the following code is executed which
basically opens the form hidden and sets the cboGroomerID combo to the
first hidden field of the listbox.
Next, a subform control(named Clients on the main form) is synched to
the hidden clientID from the listbox.
Problem is that if I step through the code the Clients subform is
synched to the clientID passed in. However, if I run the form, the
Clients subform is not synched to the passed in value as there is no
match in the recordset clone. Its almost as if there is a delay in
filling the recordset and currently client records number 10 not
hundreds...
I might also like to link the PetData subform with the selected PetID
also hidden but need to resolve this first.
Thank you in advance for your suggestions/comments,
Rey
lstCustomers_Click()
Dim lngRow As Long
Dim lngGroomerID As Long
Dim strFormName As String
Dim lngCustID As Long
Dim ctrlGroomer As Control
Dim ctrlFName As Control
Dim ctrlLName As Control
Dim strCriteria As String
Dim frm As Form
strFormName = "Groomers_SidebySide"
' get lngGroomerID from 1st column in listbox (bound column)
lngGroomerID = lstCustomers.Value
' pulling custID from list
lngCustID = lstCustomers.Column(1)
DoCmd.OpenForm strFormName, acNormal, , , , acHidden
' access groomer combobox to set its value to groomer
Set ctrlGroomer = Forms!Groomers_SidebySide.Form.Controls.Item
("cboGroomerID")
Set ctrlFName = Forms!Groomers_SidebySide.Form.Controls.Item
("txtFirstName")
Set ctrlLName = Forms!Groomers_SidebySide.Form.Controls.Item
("txtLastName")
ctrlGroomer.Value = lngGroomerID
ctrlGroomer.Requery
ctrlFName = ctrlGroomer.Column(2)
ctrlLName = ctrlGroomer.Column(1)
' now to set the client subform to clientID value
' Define search criteria
strCriteria = "ClientID = " & lngCustID
Set frm = Forms!Groomers_SidebySide!Clients.Form
'sSleep (4000)
With frm.RecordsetClone
.FindFirst strCriteria
If .NoMatch Then
MsgBox "not found"
Else
frm.Bookmark = .Bookmark
End If
End With
Set frm = Nothing
' this redisplays form
DoCmd.SelectObject acForm, strFormName, False
' exit search form
DoCmd.Close acForm, "frmSearch", acSaveNo
Set ctrlGroomer = Nothing
Tables:
Groomers (PKey - GroomerID)
Linked 1-M with Clients on GroomerID
Clients (PKey - ClientID)
Linked 1-M with PetData on ClientID
PetData (PKey - PetID)
Linked 1-M with GroomingVisits on PetID
GroomingVisits (PKey - VisitID)
My search form has a list box displaying the results of a wild card
search for first or last name or pet name.
When listbox is clicked, the following code is executed which
basically opens the form hidden and sets the cboGroomerID combo to the
first hidden field of the listbox.
Next, a subform control(named Clients on the main form) is synched to
the hidden clientID from the listbox.
Problem is that if I step through the code the Clients subform is
synched to the clientID passed in. However, if I run the form, the
Clients subform is not synched to the passed in value as there is no
match in the recordset clone. Its almost as if there is a delay in
filling the recordset and currently client records number 10 not
hundreds...
I might also like to link the PetData subform with the selected PetID
also hidden but need to resolve this first.
Thank you in advance for your suggestions/comments,
Rey
lstCustomers_Click()
Dim lngRow As Long
Dim lngGroomerID As Long
Dim strFormName As String
Dim lngCustID As Long
Dim ctrlGroomer As Control
Dim ctrlFName As Control
Dim ctrlLName As Control
Dim strCriteria As String
Dim frm As Form
strFormName = "Groomers_SidebySide"
' get lngGroomerID from 1st column in listbox (bound column)
lngGroomerID = lstCustomers.Value
' pulling custID from list
lngCustID = lstCustomers.Column(1)
DoCmd.OpenForm strFormName, acNormal, , , , acHidden
' access groomer combobox to set its value to groomer
Set ctrlGroomer = Forms!Groomers_SidebySide.Form.Controls.Item
("cboGroomerID")
Set ctrlFName = Forms!Groomers_SidebySide.Form.Controls.Item
("txtFirstName")
Set ctrlLName = Forms!Groomers_SidebySide.Form.Controls.Item
("txtLastName")
ctrlGroomer.Value = lngGroomerID
ctrlGroomer.Requery
ctrlFName = ctrlGroomer.Column(2)
ctrlLName = ctrlGroomer.Column(1)
' now to set the client subform to clientID value
' Define search criteria
strCriteria = "ClientID = " & lngCustID
Set frm = Forms!Groomers_SidebySide!Clients.Form
'sSleep (4000)
With frm.RecordsetClone
.FindFirst strCriteria
If .NoMatch Then
MsgBox "not found"
Else
frm.Bookmark = .Bookmark
End If
End With
Set frm = Nothing
' this redisplays form
DoCmd.SelectObject acForm, strFormName, False
' exit search form
DoCmd.Close acForm, "frmSearch", acSaveNo
Set ctrlGroomer = Nothing
Tables:
Groomers (PKey - GroomerID)
Linked 1-M with Clients on GroomerID
Clients (PKey - ClientID)
Linked 1-M with PetData on ClientID
PetData (PKey - PetID)
Linked 1-M with GroomingVisits on PetID
GroomingVisits (PKey - VisitID)