Dear All,
I have been having a problem with the following code: - Private Sub Solar_Lantern_No_AfterUpdate()
-
Dim vCheckEntry As Boolean
- vCheckEntry = DLookup("[Solar Lantern No]", "Beneficiary", "[Solar Lantern No] = " & Me.Solar_Lantern_No)
-
If vCheckEntry = True Then
-
MsgBox "Solar Lantern NO. already exists. Please change it.", vbInformation, "Beneficiary"
-
Cancel = True
-
Me.Solar_Lantern_No.SetFocus
-
Else
-
Me.Name_of_the_Beneficiary.SetFocus
-
End If
-
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
5 996
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
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
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. :)
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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" ?>...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
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...
|
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,...
|
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...
|
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...
| |