Douglas J. Steele said:
What are your Regional Settings? Might you have them set such that you
need
to use a semicolon rather than a comma as a list separator?
See whether this works:
IF Dcount("*";"q_OpSupSecurity";"UserID=" & txtUserId1 & _
" AND "SecLevelOp<3") = 0 THEN
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
John,
I apologize for being dense, but when I plug this in I get a 'Expected:
list
separator or )' error. The code I plugged in is as follows:
IF Dcount("*","q_OpSupSecurity","UserID=" & txtUserId1 & " AND
"SecLevelOp<3") = 0 THEN
I am still very new to VB/VBA and have fits trying to debug... I have
learned a LOT from you guys here, but still have a ways to go before I
even
consider myself 'literate' with this programming thing.
R Brown
:
So you can expand the criteria to something like the following
assuming
that you have a field named Clearance and it is a number field.
IF Dcount("*","q_OpSupSecurity","UserID=" & txtUserId1 & " AND
Clearance
<3") = 0 THEN
'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
iamrdbrown wrote:
Actually, I am trying to confirm that the UserID is in the table
with
the
correct clearance (<3) before allowing the data being input into the
textbox
to be saved. I don't want just ID number to work - just the ones
with
the
appropriate clearance.
TIA,
R Brown
:
You cannot use a query that way.
Perhaps what you want is to use the DCount function to see if the
id
already
exists in a table or a query.
IF Dcount("*","q_OpSupSecurity","UserID=" & txtUserId1) = 0 THEN
MsgBox "Invalid Operator ID. Please try it again.", _
vbExclamation, "Operator ID Entry"
txtUserID1 = 0
txtUserID1.SetFocus
End If
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
iamrdbrown wrote:
I am trying to use a query (q_OpSupSecurity) with a 'IsNull' to
limit
input
to a textbox. The query is based on a table where Operators =1
and
Supervisors = 2. The query is acting as a filter to remove values
that
shouldn't be allowed into this textbox.
I get a "Microsoft Office Access can't find the field '|' referred
to
in
your expression" error when I try to run the code. How else can I
accomplish
what I am trying to do with this code?
Private Sub txtUserID1_AfterUpdate()
If IsNull([q_OpSupSecurity]) Then
MsgBox "Invalid Operator ID. Please try it again.",
vbExclamation,
"Operator ID Entry"""
txtUserID1 = 0
txtUserID1.SetFocus
End If
End Sub
Thanks in advance,
R Brown