Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lookup combo box on form - error 3077 1

Status
Not open for further replies.

SNicholls

Technical User
May 13, 2004
22
US
I have a database of about 10 tables, 300 records. ProjectName is the primary field.
There's a (single view) form that shows the data; it contains a lookup combo box to take the viewer directly to that item in the form.
In the combo box, there's this AfterUpdate event procedure:

Private Sub cmboLookup_AfterUpdate()

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ProjectName] = '" & Me![cmboLookup] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub

The data entry person reported that three of the records she has added cause an error in the lookup field (run-time error 3077). All others work correctly. On debug, this line is highlighted:

rs.FindFirst "[ProjectName] = '" & Me![cmboLookup] & "'"

The names in the lookup table use the supporting table as source, so there's no discrepancy in ProjectName. I don't see what's different about the three entries that provoke the error. Any help would be appreciated.

S. Nicholls
 
Would it by any chance contain special characters, for instance a single quote? If so, try:

[tt] rs.FindFirst "[ProjectName] = """ & Me![cmboLookup] & """"
' or
rs.FindFirst "[ProjectName] = '" & replace(Me![cmboLookup], "'","''") & "'"[/tt]

Roy-Vidar
 
Yes! That fixed it. Thanks very much.

Sabrina
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top