473,785 Members | 2,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.U ndo
DoCmd.RunComman d 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 1496
try

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

hth
"sparks" <js******@swbel l.netwrote in message
news:li******** *************** *********@4ax.c om...
If Not IsNull(DLookup([Office_use], "tblDemographic ", "[Office_use] =
""" & Me.Text9 & """")) Then
Cancel = True
MsgBox "Duplicate Value is Not Allowed"
ActiveControl.U ndo
DoCmd.RunComman d 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.U ndo
DoCmd.RunComman d 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("*","tbl Demographic", "[Office_use] = """ & Me.Text9 & """")
0 Then
MsgBox "Duplicate Value is Not Allowed".
Cancel = True
ActiveControl.U ndo
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.RunComman d 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******@examp le.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.U ndo
DoCmd.RunComman d 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("*","tbl Demographic", "[Office_use] = """ & Me.Text9 & """")
>0 Then
MsgBox "Duplicate Value is Not Allowed".
Cancel = True
ActiveControl.U ndo
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.RunComman d 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.U ndo
DoCmd.RunComman d 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
2339
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 field is "class code." I want a text box to be populated with the "title" which corresponds to the "class code" which I enter in the form. The control source for the text box is:
2
2950
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 a form with a field that automatically popluates with todays date called "created date". I have another field on the form called "Processing Month1" that I want to update automatically base on a schedule in a
1
5252
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 subreports, filters perfectly, with the exception of a running sum DLookup field on the main report. This field looks up a value in a foreign table. I'm not clear where I'm supposed to be filtering this field, since it obviously isn't picking up the...
11
2231
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 tblPreliminaryVINs is a 17-char text field. Forms!frmVINODO!SerialNum is just an unbound textbox on a form (frmVINODO). I run the DLookup during the textbox's BeforeUpdate event code. Some VIN values I type in there do NOT give rise to the error. Some do. By
2
2346
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) that returns all staffs duties for a selected day.e.g. Fullname Duty Name1 E1 Name2 Sick Name3 Pwk N2
1
1805
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 will post what I have tried so far and hopefully someone can help me problem solve. I have tried three different methods... (I know Calculation is spelled wrong..I have to go through my database and fix it everywhere just haven't had the time...
2
9046
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 hand? Table name: LUtblProvider Table field names: provPKID, name, company, type, phone Table name: tblRef Table field names: refPKID, prov, event, src
1
485
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 have used this syntax but get the error message "can't find TableB.Field 7": DLookup("","",".=.")
7
2059
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" field. The Dlookup seems to work fine on its own. I tested it with a text box that was set to: = DLookup("", "", " = " & !!) and it would bring back the correct data. Then what I need it to do is check to see if the Dlookup return...
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9489
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9959
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.