Runtime Error '3077' in combo box

  • Thread starter Dewan Choudhury via AccessMonster.com
  • Start date
D

Dewan Choudhury via AccessMonster.com

Hi,

I have a combo box on a form that finds records in a table or query. It works fine except for string with an apostrophe on it - and the string is,

IED_Headcount 'ADODB' error message

It gives me a 3077 runtime error (Missing operator in expression). I found out the reason I am getting this error is because the word 'ADODB' has aphostrophe on it.

My code for the Find Records Combo Box is,

Private Sub Combo84_AfterUpdate()
Dim rs As Object

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

End Sub

Can you please help me with the necessary code to escape the error.

I certainly appreciate your help and thank you in advance.

Dewan

*****************************************
* This message was posted via http://www.accessmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://www.accessmonster.com/Uwe/Abuse.aspx?aid=b89e6bd0155940a38320c6d6738f8283
*****************************************
 
D

Douglas J. Steele

You need to replace each occurrence of a single quote with two single
quotes.

Assuming you're using Access 2000 or newer, try

rs.FindFirst "[Issue] = '" & Replace(Me![Combo84], "'", "''") & "'"

Exagerated for clarity, that's

rs.FindFirst "[Issue] = ' " & Replace(Me![Combo84], " ' ", " ' ' ") & "
' "

Another possibility is

rs.FindFirst "[Issue] = " & Chr$(34) & Me![Combo84] & Chr$(34)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Dewan Choudhury via AccessMonster.com said:
Hi,

I have a combo box on a form that finds records in a table or query. It
works fine except for string with an apostrophe on it - and the string is,
IED_Headcount 'ADODB' error message

It gives me a 3077 runtime error (Missing operator in expression). I found
out the reason I am getting this error is because the word 'ADODB' has
aphostrophe on it.
My code for the Find Records Combo Box is,

Private Sub Combo84_AfterUpdate()
Dim rs As Object

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

End Sub

Can you please help me with the necessary code to escape the error.

I certainly appreciate your help and thank you in advance.

Dewan

*****************************************
* This message was posted via http://www.accessmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://www.accessmonster.com/Uwe/Abuse.aspx?aid=b89e6bd0155940a38320c6d6738f8283
*****************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Combo Box Error 3077 - Access 2003 1
Run time error 3077 1
Search combo box 2
RunTime Error 3070 11
Run Time error 3077 1
Combo Box recordset problem 2
Combo Box Syntax Error 1
Error 2147352567 2

Top