>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
[quoted text clipped - 10 lines]
>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....
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
******************************************************************************************
On Thu, 31 May 2007 14:17:07 -0700, "Ynot" <a_ursoNOSPAM@hotmail.com>
wrote:
>Sorry for lack of clarity, let me restate the issue. I want the
>"statement"
[quoted text clipped - 13 lines]
>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@Home.com
Douglas J. Steele - 01 Jun 2007 00:49 GMT
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

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
> 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
[quoted text clipped - 54 lines]
> Bob Hairgrove
> NoSpamPlease@Home.com
Ynot - 01 Jun 2007 01:41 GMT
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?
> Are you saying that AuthFunction contains the name of a field in the
> recordset?
[quoted text clipped - 61 lines]
>> Bob Hairgrove
>> NoSpamPlease@Home.com
Douglas J. Steele - 01 Jun 2007 12:00 GMT
I'm not aware of that capability. I don't believe Eval will do it: certain a
test I ran just now didn't work.

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> Doug,
>
[quoted text clipped - 78 lines]
>>> Bob Hairgrove
>>> NoSpamPlease@Home.com
rwr - 01 Jun 2007 14:49 GMT
> Doug,
>
[quoted text clipped - 8 lines]
>
> if compvalue = "Home" then.....
cut
I don't think Access has anything like what you want. A number of years
ago I converted a Visual FoxPro program I wrote to Access and had to
chang the FoxPro version of Eval to use code like Doug gave you.
As I remember it FoxPro used a @ or & in front of the variable.
I think the reason it doesn't work is because of how the code is complied.
Ron