G
Guest
Hi
I have a combo box on my form (frmclientpricingenter) which pulls up a
record and displays the record on form.
I want to enter a value into the combobox, using code, from another form and
then the combobox pulls up the appropriate record.
I am able to populate the combobox but it wont pull up the required record.
If I manually select the record using the combobox it works fine.
Code for Combo box is as follows
Private Sub Combo9_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Client Name] = '" & Me![Combo9] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
Code to open the form with a new record andpopulate the combobox with a value
Private Sub cmdaddpricing_Click()
On Error GoTo Err_cmdaddpricing_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmmtclientpricingenter"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
Forms!frmmtclientpricingenter![Combo9].Value =
Forms!frmassistcliententry![Client Name]
Exit_cmdaddpricing_Click:
Exit Sub
Err_cmdaddpricing_Click:
MsgBox Err.description
Resume Exit_cmdaddpricing_Click
End Sub
Am I using the wrong event on the combo box
Thanks
Richard
I have a combo box on my form (frmclientpricingenter) which pulls up a
record and displays the record on form.
I want to enter a value into the combobox, using code, from another form and
then the combobox pulls up the appropriate record.
I am able to populate the combobox but it wont pull up the required record.
If I manually select the record using the combobox it works fine.
Code for Combo box is as follows
Private Sub Combo9_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Client Name] = '" & Me![Combo9] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
Code to open the form with a new record andpopulate the combobox with a value
Private Sub cmdaddpricing_Click()
On Error GoTo Err_cmdaddpricing_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmmtclientpricingenter"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
Forms!frmmtclientpricingenter![Combo9].Value =
Forms!frmassistcliententry![Client Name]
Exit_cmdaddpricing_Click:
Exit Sub
Err_cmdaddpricing_Click:
MsgBox Err.description
Resume Exit_cmdaddpricing_Click
End Sub
Am I using the wrong event on the combo box
Thanks
Richard