I need some of your expertise here.
I have a form frmEnterBill. On this form I have an Account# text box and a CompanyName text box (as well as some others). I have a table: Accounts with Account # and CompanyName. I have code in the AfterUpdate event of the Account# field in the form to populate the CompanyName textbox on the same form by pulling CompanyName from the Accounts table that matches the AccountNumber entered in the form. The code reads as follows: -
-
Dim varCompName As Variant
-
varCompName = Lookup "CompanyName", "Accounts", "AccountNumber_
-
=[AccountNumber] ")
-
If (Not IsNull(varCompName)) Then Me![CompanyName] = varCompName
-
No matter what Account Number I enter, I only get a CompanyName of my 2nd record in the Accounts table.
Can anyone suggest some update to my code to fix this?
Any help would be much appreciated.
Thanks,
RAY
3 2001 PEB 1,418
Recognized Expert Top Contributor
Hi Ray,
Try this code: -
-
Dim varCompName As Variant
-
varCompName = DLookup ("CompanyName", "Accounts", "AccountNumber_
-
="+Str(Me![AccountNumber]))
-
If (Not IsNull(varCompName)) Then Me![CompanyName] = varCompName
-
Best regards!
I need some of your expertise here.
I have a form frmEnterBill. On this form I have an Account# text box and a CompanyName text box (as well as some others). I have a table: Accounts with Account # and CompanyName. I have code in the AfterUpdate event of the Account# field in the form to populate the CompanyName textbox on the same form by pulling CompanyName from the Accounts table that matches the AccountNumber entered in the form. The code reads as follows: -
-
Dim varCompName As Variant
-
varCompName = Lookup "CompanyName", "Accounts", "AccountNumber_
-
=[AccountNumber] ")
-
If (Not IsNull(varCompName)) Then Me![CompanyName] = varCompName
-
No matter what Account Number I enter, I only get a CompanyName of my 2nd record in the Accounts table.
Can anyone suggest some update to my code to fix this?
Any help would be much appreciated.
Thanks,
RAY
Thank you for your response. I have corrected the code, but now when I try to enter an Account # that I know is in the Accounts table, I get:
Data type mismatch in criteria expression. (Error 3464)
From Help:
The criteria expression in a Find method is attempting to compare a field with a value whose data type does not match the field’s data type.
Could you provide a bit more guidance?
Thanks,
Ray
Hi Ray,
Try this code: -
-
Dim varCompName As Variant
-
varCompName = DLookup ("CompanyName", "Accounts", "AccountNumber_
-
="+Str(Me![AccountNumber]))
-
If (Not IsNull(varCompName)) Then Me![CompanyName] = varCompName
-
Best regards!
PEB 1,418
Recognized Expert Top Contributor
Dim varCompName
varCompName = DLookup ("CompanyNam e", "Accounts", "AccountNum ber_
="+Str(Me![AccountNumber]))
If (Not IsNull(varCompN ame)) Then Me![CompanyName] = varCompName
The proble may be caused by this expression: "AccountNum ber ="+Str(Me![AccountNumber])
So if your AccountNumber is defined in your database as Text you need to do:
Dim varCompName
varCompName = DLookup ("CompanyNam e", "Accounts", "AccountNum ber_
='"+Str(Me![AccountNumber])+"'")
If (Not IsNull(varCompN ame)) Then Me![CompanyName] = varCompName
Best regards!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Sylvie Stone |
last post by:
Hi group -
I have an html form for that uses username and password to login to a
specific area of the website. The "area" the user wants to go to is
based on a pull down menu. Becasue the user/password info is in
differnet databases, how can I call different validation scripts based
on this input ?
THANK YOU!
See below please. Somethinglike this:
|
by: David Girard |
last post by:
I'm getting the following error which is no big deal - the
problem is it is LOCATION specific - which has me really
baffled... for some reason the error only appears on
different machines in different various locations. I've
checked the versions of browsers and I've tried from at
least 10 different pc's in different locations and the
page comes up perfect. My web server is up to date with
all current patches. Occasionally, someone will...
|
by: Martin |
last post by:
Hi Guys,
I am a bit of a JavaScript rookie, so please bear with me ....
Some time ago, I asked for help with some code to populate a drop down
country box based on a value I was returning from a popup menu.
This is all now working fine (Thanks !) but I have noticed, it
unfortunately does not scale well, and is causing quite some delay
between the user hitting 'go', and the country
|
by: x muzuo |
last post by:
Hi guys,
I have got a prob of javascript form validation which just doesnt work
with my ASP code. Can any one help me out please.
Here is the code:
{////<<head>
<title>IIBO Submit Page</title>
</head>
<style type="text/css">
|
by: David. E. Goble |
last post by:
Hi all; I have the following files; index.html, sigsheader.js,
sigsboby.js, smilesbody.js and smiles.js. The sourse is below.
The page displays two manual slide shows... Each slideshow has a set
of buttons. the top slideshow (the smiles work fine. How ever the sigs
slideshow displays the pictures in the smiles section.
*************** index.html *****************************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01...
| |
by: Steph |
last post by:
Hi.
I'm very new to MS Access and have been presented with an Access database
of contacts by my employer.
I am trying to redesign the main form of the database so that a button
entitled 'search' may be clicked on by the user and the user can then
search all records by postcode. I want to do this to prevent duplicate
data entry.
|
by: David. E. Goble |
last post by:
Arrrh! some buttons work while others don't, but I can't see why. I
have tried comparing the files that do work, with the ones that don't.
But to no help.
The funny thing is the parts that work have the same code, except
different variables.
(Note Javascript and htm code was writen by a c program, the code then
run thru a html to js converter)
|
by: phanimadhav |
last post by:
Hi,
i am working on the coding part which is based on jsp/html.As im fresher i am facing some problems with the code.so,can u please guide me..This is the error which i ve got...please have a look....
org.apache.jasper.JasperException: /jsp/DeleteUserDetail.jsp(103,0) The end tag "</html:html" is unbalanced
code follows..
<%@ taglib uri="/WEB-INF/struts-html" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic" prefix="logic"...
|
by: ramprat |
last post by:
I am using a Dlookup to pull a value from my traffic table for a record prior to moving that record to a traffic_history table. I want to take the value and store it in a variable and then populate a new record in the traffic table with that value based on a unique PCID. This code is triggered by the click event of a button on my form after someone enters a new traffic count into my continuous form. The code takes the old count and puts it into...
|
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,...
|
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...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |