Combo Box Headache

jkfeagle

Codus Confusious
Local time
Today, 15:36
Joined
Aug 22, 2002
Messages
166
I have two combo boxes, one on a main form and one on a subform. The two forms are not linked but are used to select to data records in two separate tables that you want linked. The linking is done by code behind a button. That works fine. What doesn't always work are the two combo boxes. The one on the main form works fine until I try to select the last entry in the list. Then I get the following error:

Run-Time Error '3077'"
Syntax error (missing operator) in expression

How could that be possible when it is working for the other records? Also the code was wizard generated. Here is the code:

Private Sub Combo12_AfterUpdate()
' Find the record that matches the control
Dim rs As Object

Set rs=Me.Recordset.Clone
rs.FindFirst "[ItemDescription] = '" & Me![Combo12] & "'"
Me.Bookmark = rs.Bookmark
End Sub

The second has exactly the same code but periodically gives me a different error:

'No records found'

This is really peculiar considering that the values are showing up in the combo box and when I check the table it is searching, the values are in fact there. I suspect that this may be a matter of resetting the pointer but I'm not sure. Anyone have any ideas??
 
This might not be it, but have you tried moving the code to the OnClick Event of the Combobox instead of the AfterUpdate?

That might not help, but here is another thing you could try:

Change Dim rs as Object to Dim rs as Variant

But I might just be shooting in the dark.
 
OK. The quote issue solved my first problem but the 'No Current Record' error still remains on the subform combo box. I realized it could well be because it defaulted to the Me! reference which does not work on subforms. I have tried to get the syntax right to reference the subform (subfrmGetHTMLTableInfo) but to no avail. Can SOMEBODY tell me what I'm doing wrong before I pull out my last hair. Main form name is frmMatchOrphanItems. Below is the code. Thanks for any help!!

Private Sub Title_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Forms![frmMatchOrphanItems]![subfrmGetHTMLTableInfo].Recordset.Clone

rs.FindFirst "Forms![frmMatchOrphanItems]![subfrmGetHTMLTAbleInfo].Form![Title] = "" & Forms![frmMatchOrphanItems]![subfrmGetHTMLTAbleInfo].Form![Title] & """
Forms![frmMatchOrphanItems]![subfrmGetHTMLTableInfo].Bookmark = rs.Bookmark

End Sub
 

Users who are viewing this thread

Back
Top Bottom