Re: use value of variable in a statement
- From: "Ynot" <a_ursoNOSPAM@xxxxxxxxxxx>
- Date: Thu, 31 May 2007 17:41:33 -0700
Doug,
THANX!!!! That solves my problem. I tested it and it works. THANX!!!!
Was I wrong though??? That is still bothering me!!!
Isn't there a pair of characters or something that will allow a replacement
of a variable with the content of the variable in a statement prior to
execution?
Like:
if compvalue = "Home" then.....
Where "compvalue" is replaced by its content like "home" or "office" or
"mobile" etc prior to the compare?
"Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx> wrote in message
news:ux2eO59oHHA.1240@xxxxxxxxxxxxxxxxxxxxxxx
Are you saying that AuthFunction contains the name of a field in the
recordset?
If rst.Fields(AuthFunction) <> True Then
rtxx = MsgBox("You are not authorized for this function", vbCritical)
End If
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"Ynot" <a_ursoNOSPAM@xxxxxxxxxxx> wrote in message
news:uWHLVr9oHHA.1240@xxxxxxxxxxxxxxxxxxxxxxx
Maybe I'm not getting it and still can't find an example of what I want
to do but I do remember seeing it done. Here is the exact code. I have
tried several variations of brackets etc so that The variable
"AuthFunction" is replaced in the IF statement with the value in the
variable.
************************************************************************************
Public Function checkAuth(Badge, AuthFunction) As String
Dim strsql, rtxx As String
Dim rst As Recordset
strsql = "SELECT authtocoll, "
strsql = strsql & "authtodel, "
strsql = strsql & "authtoMachine, "
strsql = strsql & "authtoadmin, "
strsql = strsql & "authoffhourentry, "
strsql = strsql & "authtomaint "
strsql = strsql & "FROM members WHERE MEMBERBADGENUMBER = " & Badge & ";"
Set rst = CurrentDb.OpenRecordset(strsql)
If rst.[Eval("AuthFunction")] <> True Then
rtxx = MsgBox("You are not authorized for this function",
vbCritical)
checkAuth = False
End If
rst.Close
End Function
******************************************************************************************
"Bob Hairgrove" <invalid@xxxxxxxxxxx> wrote in message
news:behu53dlk171slhi9r19qq737ptfi4ubp1@xxxxxxxxxx
On Thu, 31 May 2007 14:17:07 -0700, "Ynot" <a_ursoNOSPAM@xxxxxxxxxxx>
wrote:
Sorry for lack of clarity, let me restate the issue. I want the
"statement"
to be modified and the variable name to be replaced with the variable
content. better example
strcompare = "screenName"
If strcompare = "ynot" then... This
statement would execute as :
If screenName = "ynot" then......
That is where I want the value of the variable to replace the variable
name.
I thought there were special characters to wrap the variable name in so
that
the name is replaced by the content... BUT I can't find it....
Check out the Eval() function ... this might be what you want.
--
Bob Hairgrove
NoSpamPlease@xxxxxxxx
.
- Follow-Ups:
- Re: use value of variable in a statement
- From: rwr
- Re: use value of variable in a statement
- From: Douglas J. Steele
- Re: use value of variable in a statement
- References:
- Re: use value of variable in a statement
- From: Ynot
- Re: use value of variable in a statement
- From: Bob Hairgrove
- Re: use value of variable in a statement
- From: Ynot
- Re: use value of variable in a statement
- From: Douglas J. Steele
- Re: use value of variable in a statement
- Prev by Date: RE: Insert new value to a table
- Next by Date: Re: Maiilng list application
- Previous by thread: Re: use value of variable in a statement
- Next by thread: Re: use value of variable in a statement
- Index(es):
Relevant Pages
|