PC Review


Reply
Thread Tools Rate Thread

apostrophie in field value causes problems

 
 
RonM
Guest
Posts: n/a
 
      26th Sep 2003
I have a command button that runs fine as long as there is
not an apostrophie in the field value for [Location_Name].
i.e. if [Location_Name]="Joe's Grill"
I'm sure this is very simple to fix, I'm just a rookie...
Here is the code:

Private Sub Assignments_Btn_Click()
On Error GoTo Err_Assignments_Btn_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Assignments_By_Co"

stLinkCriteria = "[Location_Name]=" & "'" & Me!
[Location_Name] & "'"

DoCmd.OpenForm stDocName, , , stLinkCriteria
Thanks,
RM

 
Reply With Quote
 
 
 
 
Cheryl Fischer
Guest
Posts: n/a
 
      26th Sep 2003
Ron,

There are a couple of ways to get around this. Here's one, using Chr(34):

stLinkCriteria = "[Location_Name]=" & Chr(34) & Me![Location_Name] &
Chr(34)

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

"RonM" <(E-Mail Removed)> wrote in message
news:1c7a01c3841e$48ad0610$(E-Mail Removed)...
> I have a command button that runs fine as long as there is
> not an apostrophie in the field value for [Location_Name].
> i.e. if [Location_Name]="Joe's Grill"
> I'm sure this is very simple to fix, I'm just a rookie...
> Here is the code:
>
> Private Sub Assignments_Btn_Click()
> On Error GoTo Err_Assignments_Btn_Click
>
> Dim stDocName As String
> Dim stLinkCriteria As String
>
> stDocName = "Assignments_By_Co"
>
> stLinkCriteria = "[Location_Name]=" & "'" & Me!
> [Location_Name] & "'"
>
> DoCmd.OpenForm stDocName, , , stLinkCriteria
> Thanks,
> RM
>



 
Reply With Quote
 
RobFMS
Guest
Posts: n/a
 
      26th Sep 2003
Ron

You will want to change the single quote to 2 double quotes, using the
Replace() function (Access 2000 & up)

= Replace(<string to search in>, "'", "''", 1, , vbTextCompare)

HTH

--

Rob

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Need to launch your application in the appropriate version of Access?
http://www.fmsinc.com/Products/startup/index.asp

Need software tools for Access, VB, SQL or .NET?
http://www.fmsinc.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



"RonM" <(E-Mail Removed)> wrote in message
news:1c7a01c3841e$48ad0610$(E-Mail Removed)...
> I have a command button that runs fine as long as there is
> not an apostrophie in the field value for [Location_Name].
> i.e. if [Location_Name]="Joe's Grill"
> I'm sure this is very simple to fix, I'm just a rookie...
> Here is the code:
>
> Private Sub Assignments_Btn_Click()
> On Error GoTo Err_Assignments_Btn_Click
>
> Dim stDocName As String
> Dim stLinkCriteria As String
>
> stDocName = "Assignments_By_Co"
>
> stLinkCriteria = "[Location_Name]=" & "'" & Me!
> [Location_Name] & "'"
>
> DoCmd.OpenForm stDocName, , , stLinkCriteria
> Thanks,
> RM
>



 
Reply With Quote
 
RonM
Guest
Posts: n/a
 
      29th Sep 2003
Thanks, that worked.
RM
P.S.
After my post I started getting email containing a worm.
Is this a problem on this forum? I'll use a fake email
from now on!


>-----Original Message-----
>Ron,
>
>There are a couple of ways to get around this. Here's

one, using Chr(34):
>
>stLinkCriteria = "[Location_Name]=" & Chr(34) & Me!

[Location_Name] &
>Chr(34)
>
>--
>Cheryl Fischer
>Law/Sys Associates
>Houston, TX
>
>"RonM" <(E-Mail Removed)> wrote in message
>news:1c7a01c3841e$48ad0610$(E-Mail Removed)...
>> I have a command button that runs fine as long as there

is
>> not an apostrophie in the field value for

[Location_Name].
>> i.e. if [Location_Name]="Joe's Grill"
>> I'm sure this is very simple to fix, I'm just a

rookie...
>> Here is the code:
>>
>> Private Sub Assignments_Btn_Click()
>> On Error GoTo Err_Assignments_Btn_Click
>>
>> Dim stDocName As String
>> Dim stLinkCriteria As String
>>
>> stDocName = "Assignments_By_Co"
>>
>> stLinkCriteria = "[Location_Name]=" & "'" & Me!
>> [Location_Name] & "'"
>>
>> DoCmd.OpenForm stDocName, , , stLinkCriteria
>> Thanks,
>> RM
>>

>
>
>.
>

 
Reply With Quote
 
Cheryl Fischer
Guest
Posts: n/a
 
      29th Sep 2003
> After my post I started getting email containing a worm.
> Is this a problem on this forum? I'll use a fake email
> from now on!


Ron,

It's a problem everywhere these past couple of weeks. Spammers have
routinely harvested email addresses from a variety of internet resources,
UseNet newsgroups included. Unfortunately, this current outbreak spread
extremely quickly.

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

"RonM" <(E-Mail Removed)> wrote in message
news:133801c38685$e81f65d0$(E-Mail Removed)...
> Thanks, that worked.
> RM
> P.S.
> After my post I started getting email containing a worm.
> Is this a problem on this forum? I'll use a fake email
> from now on!
>
>
> >-----Original Message-----
> >Ron,
> >
> >There are a couple of ways to get around this. Here's

> one, using Chr(34):
> >
> >stLinkCriteria = "[Location_Name]=" & Chr(34) & Me!

> [Location_Name] &
> >Chr(34)
> >
> >--
> >Cheryl Fischer
> >Law/Sys Associates
> >Houston, TX
> >
> >"RonM" <(E-Mail Removed)> wrote in message
> >news:1c7a01c3841e$48ad0610$(E-Mail Removed)...
> >> I have a command button that runs fine as long as there

> is
> >> not an apostrophie in the field value for

> [Location_Name].
> >> i.e. if [Location_Name]="Joe's Grill"
> >> I'm sure this is very simple to fix, I'm just a

> rookie...
> >> Here is the code:
> >>
> >> Private Sub Assignments_Btn_Click()
> >> On Error GoTo Err_Assignments_Btn_Click
> >>
> >> Dim stDocName As String
> >> Dim stLinkCriteria As String
> >>
> >> stDocName = "Assignments_By_Co"
> >>
> >> stLinkCriteria = "[Location_Name]=" & "'" & Me!
> >> [Location_Name] & "'"
> >>
> >> DoCmd.OpenForm stDocName, , , stLinkCriteria
> >> Thanks,
> >> RM
> >>

> >
> >
> >.
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
apostrophie and an inverted V when copy/paste RK Microsoft Excel Misc 1 16th Sep 2009 08:36 PM
Subform Field Problems =?Utf-8?B?V01vcnNiZXJnZXI=?= Microsoft Access Forms 0 4th Oct 2006 08:14 PM
Problems setting focus on a field, locked into field... =?Utf-8?B?YWVtQW5keQ==?= Microsoft Access Form Coding 2 9th Feb 2006 07:47 PM
To and From field problems =?Utf-8?B?cm1pdHRlbmVzcw==?= Microsoft Outlook Discussion 0 23rd Aug 2005 02:30 PM
Help: Problems with "Created" field; it's the same as received field Dab Microsoft Outlook 0 9th Nov 2004 12:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:58 PM.