commas in string

A

AndyM

I have a combo box called "stressbox." After an update, I'd like it to open a
separate form called "stressqueue" and find all entries for where the value
stresseng (on the form) has the same value as stressbox. This is a problem
because stressbox and stresseng all have values that have commas in them
(Lastname, First sort of things). Does anyone know how to use commas for the
below expression?
Thanks!

Dim strWhere As String
strWhere = "[stresseng] =" & Me.stressbox

DoCmd.OpenForm "stressqueue", , , "[stresseng] = " & stressbox
 
A

AndyM

Sorry, the below code should read:
Dim strWhere As String
strWhere = "[stresseng] =" & Me.stressbox

DoCmd.OpenForm "stressqueue", , , strwhere
 
D

Douglas J. Steele

Since stresseng and stressbox both contains strings, not numbers, you need
to enclose the values in quotes:

strWhere = "[stresseng] ='" & Me.stressbox & "'"

or

strWhere = "[stresseng] =" & Chr$(34) & Me.stressbox & Chr$(34)

(If there's a chance that any of the values contain apostrophes, like
"O'Reilly, Mike", use the second approach)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


AndyM said:
Sorry, the below code should read:
Dim strWhere As String
strWhere = "[stresseng] =" & Me.stressbox

DoCmd.OpenForm "stressqueue", , , strwhere

AndyM said:
I have a combo box called "stressbox." After an update, I'd like it to
open a
separate form called "stressqueue" and find all entries for where the
value
stresseng (on the form) has the same value as stressbox. This is a
problem
because stressbox and stresseng all have values that have commas in them
(Lastname, First sort of things). Does anyone know how to use commas for
the
below expression?
Thanks!

Dim strWhere As String
strWhere = "[stresseng] =" & Me.stressbox

DoCmd.OpenForm "stressqueue", , , "[stresseng] = " & stressbox
 
Top