A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Use QBE Grid with Double-Quotes and/or Apostrophe



 
 
Thread Tools Display Modes
  #1  
Old April 23rd, 2008, 05:51 PM posted to microsoft.public.access.queries
ryguy7272
external usenet poster
 
Posts: 1,593
Default Use QBE Grid with Double-Quotes and/or Apostrophe

In the QBE Grid, with Like "INT'L" in Criteria, my Query works fine. It
fails when I try to create a dynamic Query with this VBA:

' Build criteria string for Broker
For Each varItem In Me.lstBroker.ItemsSelected
strBroker = strBroker & ",'" & Me.lstBroker.ItemData(varItem) & "'"
Next varItem
If Len(strBroker) = 0 Then
strBroker = "Like " * ""
Else
strBroker = Right(strBroker, Len(strBroker) - 1)
strBroker = "IN(" & strBroker & ")"
End If

I’m sure it has to do with the ‘ in the INT’L. I tried quotes and
double-quotes, like this:
strBroker = "Like " * ""


Can’t seem to quite get it working though.

Can anyone see what the problem is?

Regards,
Ryan---


--
RyGuy
  #2  
Old April 23rd, 2008, 11:35 PM posted to microsoft.public.access.queries
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Use QBE Grid with Double-Quotes and/or Apostrophe

Ryan,
the general idea is to use 3 double quotes instead of one double quote, one
single quote and another double quote
Separated for clarity that is:
Use " " " instead of " ' "

use """ & Me.lstBroker.ItemData(varItem) & """
instead of
'" & Me.lstBroker.ItemData(varItem) & "'


Jeanette Cunningham



"ryguy7272" wrote in message
news
In the QBE Grid, with Like "INT'L" in Criteria, my Query works fine. It
fails when I try to create a dynamic Query with this VBA:

' Build criteria string for Broker
For Each varItem In Me.lstBroker.ItemsSelected
strBroker = strBroker & ",'" & Me.lstBroker.ItemData(varItem) & "'"
Next varItem
If Len(strBroker) = 0 Then
strBroker = "Like " * ""
Else
strBroker = Right(strBroker, Len(strBroker) - 1)
strBroker = "IN(" & strBroker & ")"
End If

I'm sure it has to do with the ' in the INT'L. I tried quotes and
double-quotes, like this:
strBroker = "Like " * ""


Can't seem to quite get it working though.

Can anyone see what the problem is?

Regards,
Ryan---


--
RyGuy



  #3  
Old April 24th, 2008, 06:04 AM posted to microsoft.public.access.queries
ryguy7272
external usenet poster
 
Posts: 1,593
Default Use QBE Grid with Double-Quotes and/or Apostrophe

BRILLIANT!!

Thanks for the help last time and thanks for the help this time!!


Ryan--
PS, thanks, in advance, for the help next time...there will probably be a
next time as well...

--
RyGuy


"Jeanette Cunningham" wrote:

Ryan,
the general idea is to use 3 double quotes instead of one double quote, one
single quote and another double quote
Separated for clarity that is:
Use " " " instead of " ' "

use """ & Me.lstBroker.ItemData(varItem) & """
instead of
'" & Me.lstBroker.ItemData(varItem) & "'


Jeanette Cunningham



"ryguy7272" wrote in message
news
In the QBE Grid, with Like "INT'L" in Criteria, my Query works fine. It
fails when I try to create a dynamic Query with this VBA:

' Build criteria string for Broker
For Each varItem In Me.lstBroker.ItemsSelected
strBroker = strBroker & ",'" & Me.lstBroker.ItemData(varItem) & "'"
Next varItem
If Len(strBroker) = 0 Then
strBroker = "Like " * ""
Else
strBroker = Right(strBroker, Len(strBroker) - 1)
strBroker = "IN(" & strBroker & ")"
End If

I'm sure it has to do with the ' in the INT'L. I tried quotes and
double-quotes, like this:
strBroker = "Like " * ""


Can't seem to quite get it working though.

Can anyone see what the problem is?

Regards,
Ryan---


--
RyGuy




 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:25 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.