473,396 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

trying to use dlookup with text field but get a weird error

If Not IsNull(DLookup([Office_use], "tblDemographic", "[Office_use] =
""" & Me.Text9 & """")) Then
Cancel = True
MsgBox "Duplicate Value is Not Allowed"
ActiveControl.Undo
DoCmd.RunCommand acCmdUndo
End If

I try to do this but when you enter a text value such as A you get

"you canceled the previous operation"

and the debugger is on the IF line of the command so cancel is not
true or ??
never seen this kind of error before

Nov 8 '06 #1
4 1473
try

If Not DCount(1, "tblDemographic", _
"[Office_use] = """ & Me.Text9 & """") < 1 Then

hth
"sparks" <js******@swbell.netwrote in message
news:li********************************@4ax.com...
If Not IsNull(DLookup([Office_use], "tblDemographic", "[Office_use] =
""" & Me.Text9 & """")) Then
Cancel = True
MsgBox "Duplicate Value is Not Allowed"
ActiveControl.Undo
DoCmd.RunCommand acCmdUndo
End If

I try to do this but when you enter a text value such as A you get

"you canceled the previous operation"

and the debugger is on the IF line of the command so cancel is not
true or ??
never seen this kind of error before

Nov 8 '06 #2
On Wed, 08 Nov 2006 12:51:55 GMT, sparks wrote:
If Not IsNull(DLookup([Office_use], "tblDemographic", "[Office_use] =
""" & Me.Text9 & """")) Then
Cancel = True
MsgBox "Duplicate Value is Not Allowed"
ActiveControl.Undo
DoCmd.RunCommand acCmdUndo
End If

I try to do this but when you enter a text value such as A you get

"you canceled the previous operation"

and the debugger is on the IF line of the command so cancel is not
true or ??

never seen this kind of error before
Each argument of a DLookUp must be a string. Your first arghument is
not a string,....(If Not IsNull(DLookup([Office_use],....).

[Office_use] needs to be enclosed in Quotes, as are the other
arguments.

If Not IsNull(DLookup("[Office_use]", ...etc..) would most likely
work, but it would me simpler to just count.

If DCount("*","tblDemographic", "[Office_use] = """ & Me.Text9 & """")
0 Then
MsgBox "Duplicate Value is Not Allowed".
Cancel = True
ActiveControl.Undo
End If

As long as Cancel is an accepted argument in the sub procedure you are
writing this code, i.e. a Control's BeforeUpdate event, Cancel = True
is all you need. The DoCmd.RunCommand acCmdUndo should not be
necessary.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Nov 8 '06 #3
oh man I looked at that thing for an hr and never did see that

If Not IsNull(DLookup("[Office_use]", "tblDemographic", "[Office_use]
= '" & Me.Text9 & "'"))

what is weird if you put in 111 it works.

if you put in bbb you get
" you canceled the previous operation "

and if you put in 108b you get
" systax error (missing operator) in query expression '108b' "
this is what had me going 2 different errors based on what the leading
chr was.

thanks big time for the help

On Wed, 8 Nov 2006 08:53:16 -0800, fredg <fg******@example.invalid>
wrote:
>On Wed, 08 Nov 2006 12:51:55 GMT, sparks wrote:
>If Not IsNull(DLookup([Office_use], "tblDemographic", "[Office_use] =
""" & Me.Text9 & """")) Then
Cancel = True
MsgBox "Duplicate Value is Not Allowed"
ActiveControl.Undo
DoCmd.RunCommand acCmdUndo
End If

I try to do this but when you enter a text value such as A you get

"you canceled the previous operation"

and the debugger is on the IF line of the command so cancel is not
true or ??

never seen this kind of error before

Each argument of a DLookUp must be a string. Your first arghument is
not a string,....(If Not IsNull(DLookup([Office_use],....).

[Office_use] needs to be enclosed in Quotes, as are the other
arguments.

If Not IsNull(DLookup("[Office_use]", ...etc..) would most likely
work, but it would me simpler to just count.

If DCount("*","tblDemographic", "[Office_use] = """ & Me.Text9 & """")
>0 Then
MsgBox "Duplicate Value is Not Allowed".
Cancel = True
ActiveControl.Undo
End If

As long as Cancel is an accepted argument in the sub procedure you are
writing this code, i.e. a Control's BeforeUpdate event, Cancel = True
is all you need. The DoCmd.RunCommand acCmdUndo should not be
necessary.
Nov 8 '06 #4
The double " are confusing the operation

Try

If Not IsNull(DLookup([Office_use], "tblDemographic", "[Office_use] =
'" & Me.Text9 & "')) Then
Cancel = True
MsgBox "Duplicate Value is Not Allowed"
ActiveControl.Undo
DoCmd.RunCommand acCmdUndo
End If

Let me know how it goes.

Regards
Anthony

Nov 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: JLM | last post by:
What am I missing here? I have a form where I enter a "Class Code". This value corresponds to what sits in table "class code descriptions" along with the "title" of each "class code." Key...
2
by: Sue | last post by:
I sent an e-mail below and got a responese but i still have the #error message in the subject below: Can someone help me: questions and replies are separted by ----- -------My Questions: I have...
1
by: mstery | last post by:
I have a report generated via an ID selection made in a dropdown on a form. The report filters by an on click event in a preview report button on the form. Everything in the report, including...
11
by: MLH | last post by:
DLookup("", "tblPreliminaryVINs", "=Forms!frmVINODO!SerialNum") is giving me a Type Mismatch error. That's confusing to me and I don't know how to circumvent it. The field in...
2
by: chris.thompson13 | last post by:
I am having a problem setting the criteria part of the DLookup method correctly and am consequently getting an error message. I have a database of staff duties, part of which is a query (qryDaily)...
1
by: aharding | last post by:
Hello! I am using Access 2003 I have been playing with DLookup all morning and have not been successful yet. I have never used this function...and have some limited experience with code. I...
2
by: sfrvn | last post by:
I am embarrassed to say I cannot make this work. Recently upgraded to Access 2003, but do not know if that part of problem (AKA 'syntax change'). Would someone be kind enough to lead me by the...
1
by: zazu | last post by:
I want to look up data (in a query) in Field 1 of my main table - Table A -, where there is a match between the data in Field 2 of the main table - Table A and the data in Field 7 of Table B. I...
7
by: WannabePrgmr | last post by:
What I am trying to do is on the click event of "Command167", run a Dlookup on the number that was just typed into "cboMoveTo1" and find the value located in the table "tblName" in the "Open/Closed"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.