Regarding StlinkCriteria / String Variable

  • Thread starter Thread starter Jean
  • Start date Start date
J

Jean

Hi,

I am using MS ACCESS 2002 on Windows 2000. I want to know how to pass the
value of the global variable as part of the argument for stLinkCriteria that
specify the actual field data.

''''''' Global Variable''''''''
stWhichContact = "Me![Course Admin ContactID]"

stLinkCriteria = "[ContactID]=" & stWhichContact

How do I code the above line so, the stLinkCriteria will return the actual
field value of Me![Course Admin ContactID] ?

I want
stLinkCriteria = "[ContactID] = 2"
instead of
stLinkCriteria = "[ContactID] = Me![Course Admin ContactID]"

Thanks,

Jean
 
Hi,

I am using MS ACCESS 2002 on Windows 2000. I want to know how to pass the
value of the global variable as part of the argument for stLinkCriteria that
specify the actual field data.

''''''' Global Variable''''''''
stWhichContact = "Me![Course Admin ContactID]"

stLinkCriteria = "[ContactID]=" & stWhichContact

How do I code the above line so, the stLinkCriteria will return the actual
field value of Me![Course Admin ContactID] ?

I want
stLinkCriteria = "[ContactID] = 2"
instead of
stLinkCriteria = "[ContactID] = Me![Course Admin ContactID]"

Thanks,

Jean

Remove the quotes.

stWhichContact = Me![Course Admin ContactID]
 
Jean,

I see a couple of issues with how you are approaching this.

1) You can only use the 'Me' keyword when you are using
code behind a form unless you pass it as a parameter to
another routine. A true Global variable is declared in a
Global module, not a form module.

2) The value of your ContactID is not going to be a string
if the use of 'st' is designating a string or text variable
for your global. Therefore your "[ContactID] = " will bomb
if you hand it a string value as the ID is probably looking
for a long integer.

3) I can't see any reason to use a Global variable for what
I think that you are trying to do. ( I have been wrong
before ).

Your code at the bottom of your post looks like what has
been generated by a wizard for an OpenForm or OpenReport
command in a form's code module. If that is the case just
modify the last line to directly pull the value of the ID
off of the form and forget about trying to use another
variable...

stLinkCriteria = "[ContactID] = " & Me![Course Admin
ContactID]


Gary Miller
Sisters, OR
 
Either

stLinkCriteria = "[ContactID] = " & Me![Course Admin ContactID]

OR

stWhichContact = Me![Course Admin ContactID]
stLinkCriteria = "[ContactID] = " & stWhichContact

Assuming that [ContactID] is numeric

If [ContactID] is a String then

Either

stLinkCriteria = "[ContactID] = '" & Me![Course Admin ContactID] & "'"

OR

stWhichContact = Me![Course Admin ContactID]
stLinkCriteria = "[ContactID] = '" & stWhichContact & "'"

Assuming that Me![Course Admin ContactID] will not ever contain an
Apostrophe

If Me![Course Admin ContactID] could contain an Apostrophe then

Either

stLinkCriteria = "[ContactID] = '" & Replace(Me![Course Admin
ContactID],"'","''") & "'"

OR

stWhichContact = Replace(Me![Course Admin ContactID],"'","''")
stLinkCriteria = "[ContactID] = '" & stWhichContact & "'"
 
Back
Top