473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Run Error 3077 - The Apostrophe problem

17
I'm using multiple criteria to pull up records in a form. However, whenever the "Retailer" field has a text string with an apostophe in it (example: Fred's Electronics), it errors out "3077". I'm assuming it reads the ' and it cuts the field short. Is there any way to define the value, or write the code to handle this?

Expand|Select|Wrap|Line Numbers
  1. rs.FindFirst "[SKU] = '" & Me![SKU] & "' AND [CHANNEL] = '" & Forms!frmSpecialPricing![Retailer] & "'"
Aug 9 '07 #1
7 2978
Rabbit
12,516 Expert Mod 8TB
Try:
Expand|Select|Wrap|Line Numbers
  1. rs.FindFirst "[SKU] = """ & Me![SKU] & """ AND [CHANNEL] = """ & Forms!frmSpecialPricing![Retailer] & """"
  2.  
Aug 9 '07 #2
jclover
17
Now it's runtime error '2186'. Any thoughts?
Aug 9 '07 #3
Rabbit
12,516 Expert Mod 8TB
What about:
Expand|Select|Wrap|Line Numbers
  1. rs.FindFirst "[SKU] = ""Forms!FormName![SKU] & "" AND [CHANNEL] = ""Forms!frmSpecialPricing![Retailer]"""
  2.  
Aug 9 '07 #4
jclover
17
Seems to work. Thank you.
Aug 9 '07 #5
jclover
17
I take that back. It executes the code...no errors, but now the find function no longer works. It won't filter for any criteria.
Aug 9 '07 #6
jclover
17
I think I got it with this:

Expand|Select|Wrap|Line Numbers
  1. Dim rs As Object
  2. Set rs = Me.Recordset.Clone
  3. Dim ChannelAdj As String
  4. Dim Channel As String
  5.  
  6. Channel = Forms!frmSpecialPricing![Retailer]
  7.  
  8. If InStr(1, Channel, "'", vbTextCompare) > 0 Then
  9.     ChannelAdj = Replace(Channel, "'", "''", , , vbTextCompare)
  10. Else:
  11.     ChannelAdj = Channel
  12. End If
  13.  
  14. rs.FindFirst "[SKU] = '" & Me![SKU] & "' AND [CHANNEL] = '" & ChannelAdj & "'"
  15. If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  16.  
Aug 9 '07 #7
Rabbit
12,516 Expert Mod 8TB
I think I got it with this:

Expand|Select|Wrap|Line Numbers
  1. Dim rs As Object
  2. Set rs = Me.Recordset.Clone
  3. Dim ChannelAdj As String
  4. Dim Channel As String
  5.  
  6. Channel = Forms!frmSpecialPricing![Retailer]
  7.  
  8. If InStr(1, Channel, "'", vbTextCompare) > 0 Then
  9.     ChannelAdj = Replace(Channel, "'", "''", , , vbTextCompare)
  10. Else:
  11.     ChannelAdj = Channel
  12. End If
  13.  
  14. rs.FindFirst "[SKU] = '" & Me![SKU] & "' AND [CHANNEL] = '" & ChannelAdj & "'"
  15. If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  16.  
Excellent, thanks for posting the solution.
Aug 9 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
0
by: Jennifer | last post by:
Could you please report the following problem to your VC customer support? THANKS! Jennifer The problem is specific to the VC.Net and VC.Net 2003 <xlocinfo> headers. The problem is that if...
7
by: Jack | last post by:
Hi, I am trying to test a sql statement in Access which gives me the error as stated in the heading. The sql statement is built as a part of asp login verification, where the userid and password...
10
by: DataBard007 | last post by:
Hello Access Gurus: I use Win98SE and Access97. I just built a simple Access97 application which holds all contact information for my personal contacts, such as first name, last name, address,...
0
by: Peter Ross | last post by:
Using V1.1 of the framework, I try and compile the following as a module. #using <mscorlib.dll> __gc public class Test : public System::Object { }; $ cl /clr:noAssembly /LD test.cpp...
10
by: PufferFish | last post by:
Hi folks, I hope that this is the correct group for these things, apologies if not. I've got a strange compiler error. It appears to be similar to the issue described in knowledgebase...
9
by: VancouverMike | last post by:
Hi there, I run into a very strange problem. I got the following url and am passing information via query string. The problem when the "sin" key in query string is blank, shown as in the...
7
by: Rebecca Smith | last post by:
Today's problem is - my combo box works great until it comes across a name with an apostrophe, such as Bill's Bike Shop. I'm sure this is very common problem and I'm sure the work around is very...
0
by: snowdream1982 | last post by:
Dear all, I hit an error OVERFLOW but when I insert the sql statement below manually in the SQLEditor, it goes well, no errors at all. My coding: SQLInsertTempMf = "INSERT INTO tempmf " &...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.