Re: use value of variable in a statement

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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





.



Relevant Pages

  • Re: PIC P put to real use
    ... PICTURE and the INSPECT in such a case, because it's clearer in both ... characters being replaced as well as the replacement text! ... about the replacement of characters in a numeric-edited data item once its ... I actually like that better than the reference modification. ...
    (comp.lang.cobol)
  • Re: PIC P put to real use
    ... PICTURE and the INSPECT in such a case, because it's clearer in both ... characters being replaced as well as the replacement text! ... about the replacement of characters in a numeric-edited data item once its ... I actually like that better than the reference modification. ...
    (comp.lang.cobol)
  • Re: Need Cyrillic Font with Accents
    ... I found a replacement solution that is not too bad. ... I guess you mean "Combining Diacritical Marks". ... The idea of using such characters is in full conformance to the Unicode ... that reflects the Unicode idea of implementing combining diacritics). ...
    (comp.fonts)
  • Re: replace characters by numbers
    ... Tom Ogilvy ... "Michael E." ... sometimes the replacement logic is ... characters by numbers is mainly for statistic reasons. ...
    (microsoft.public.excel.programming)
  • Re: use value of variable in a statement
    ... Doug Steele, Microsoft Access MVP ... replacement of a variable with the content of the variable in a statement ... Dim strsql, rtxx As String ...
    (microsoft.public.access.formscoding)