473,387 Members | 1,603 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,387 software developers and data experts.

Run time error 2001

77
Dear All,

I have been having a problem with the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Solar_Lantern_No_AfterUpdate()
  2. Dim vCheckEntry As Boolean
  3. vCheckEntry = DLookup("[Solar Lantern No]", "Beneficiary", "[Solar Lantern No] = " & Me.Solar_Lantern_No)
  4.   If vCheckEntry = True Then
  5.     MsgBox "Solar Lantern NO. already exists. Please change it.", vbInformation, "Beneficiary"
  6.     Cancel = True
  7.     Me.Solar_Lantern_No.SetFocus
  8.     Else
  9.     Me.Name_of_the_Beneficiary.SetFocus
  10.   End If
  11. End Sub
The error occurs of the highlighted line. My basic idea is to check whether the primary key (Solar Lantern No) is not duplicated.

Can anyone tell me where the problem is...??

Thaning you in advance
Sajit
Apr 22 '08 #1
5 996
FishVal
2,653 Expert 2GB
Hi, Sajit.
  • I guess [Solar_Lantern_No] form control is not bound to a correspondent [Solar_Lantern_No] table field assuming [Solar_Lantern_No] table field is really set as PK. Am I right?
  • "Cancel=True" will work in event handler receiving "Cancel" argument by reference, for example in BeforeUpdate event handler. In AfterUpdate event handler it will throw an error or will do nothing depending on whether explicit variable declaration is enforced in the module or not.
  • DLookUp() function doesn't return Boolean, it returns a Variant "first" value of a field in record satisfying given criteria, if no records found it returns Null
  • The syntax of the criteria passed to DLookUp() is right for Number type table field. If [Solar_Lantern_No] table field is set as Text, then single quotes wrapping the value, [Solar_Lantern_No] table field compared to, have to be added.

Regards,
Fish
Apr 22 '08 #2
sajitk
77
Thanks Fish,

Can u give me an example of how to write this function when a text field is used...

Sajit

Hi, Sajit.
  • I guess [Solar_Lantern_No] form control is not bound to a correspondent [Solar_Lantern_No] table field assuming [Solar_Lantern_No] table field is really set as PK. Am I right?
  • "Cancel=True" will work in event handler receiving "Cancel" argument by reference, for example in BeforeUpdate event handler. In AfterUpdate event handler it will throw an error or will do nothing depending on whether explicit variable declaration is enforced in the module or not.
  • DLookUp() function doesn't return Boolean, it returns a Variant "first" value of a field in record satisfying given criteria, if no records found it returns Null
  • The syntax of the criteria passed to DLookUp() is right for Number type table field. If [Solar_Lantern_No] table field is set as Text, then single quotes wrapping the value, [Solar_Lantern_No] table field compared to, have to be added.

Regards,
Fish
Apr 22 '08 #3
sajitk
77
Now it says "Type mismatch"

sajit

Quotes (') and Double-Quotes (") - Where and When to use them
Apr 22 '08 #5
FishVal
2,653 Expert 2GB
Well. And what is the type of [Solar_Lantern_No] table field?

P.S. In post #2 I've listed possible problems with code including those not causing the fault with DLookUp() function. Also I've made some assumptions as for info you've not provided (I mean particularly table metadata). So the list is not supposed to be applied as is but in accordance with form/table settings. :)
Apr 22 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: frr | last post by:
Hi, After upgrading to 2.4 (from 2.3), I'm getting a weird syntax error: >>> import themes Traceback (most recent call last): File "<interactive input>", line 1, in ? File "themes.py", line...
2
by: Artur | last post by:
Hi Newsgroup, im currently working on programming a asp.net application consuming an Webservice hosted on Apache/Axis. I have generated WSDL and Proxy classes from VisualStudio.net. But when...
0
by: Adam Smith | last post by:
Hello. I've got a total of 5 schemas. They are: 1 - 1.xsd - a description of a city 2 - 2.xsd - a description of a town 3 - CityHall.xsd - a description of a cityhall-meant to be part of a...
1
by: Scott Dunham | last post by:
I'm trying to select records between 2 different times, but I can't seem to get Access to see anything other than the date. For instance, criteria "Between #11/12/2001 1:45:00 PM# and #11/12/2001...
1
by: Clodoaldo Pinto Neto | last post by:
Hi all, I want to have the time zone string (like 'BRT') displayed after a date-time. The date column is of the type timestamp with time zone. But the time zone is not displayed. It works for...
7
by: Jorgen Haukland, Norway | last post by:
Hi, I have created a Java webservice which runs in IBM WebSphere appserver. I take the WSDL-file and create a VS.NET WinForm application and calls the service running on my PC and everything...
1
by: Kenny Ho | last post by:
Hi, I have written the following schema that contains the XML signature: ----------------------------------------------------------------------- <?xml version="1.0" encoding="utf-8" ?>...
1
by: Moon Chung | last post by:
Hello, Has anyone used Testing Tools from WS-I (www.ws-i.org)? I am building a Web Service and hopefully it would be interoperable. When I ran Testing Tool, I am getting BP1212 error. I...
3
by: Jeremy Chapman | last post by:
I've writtin a very simple web service in axis which returns an array of classes. I consume it in a .net app. When receiving the response, my .net app generates an error "Cannot assign object...
3
by: ramprat | last post by:
Hi Sorry to keep asking questions but I keep getting a run-time error 2001 "you canceled the previous operation" error whenever the code in the Dlookup line is reached. I have a table called...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
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...

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.