473,503 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Autofill information from a table

1 New Member
I am having a hard time with my database (Access 2003) and I hope someone can help. What I doing is creating an order form, and what I would like to have happen is when a product ID is entered, the relating information to that product will self populate. I did some looking around online and in various books and was able to come up with a script. I manipulated it and tried it and it is close but not quite. Instead of populating the information that goes along with the specific product number, it just brings up the information relating to the first product in the product table.
(the product name, cost and weight comes up for the first product in my product table regardless of what product number i type in)

This is the code that I found and I have placed it in the "after update" field of the "ProdID" field in my form.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub ProdID_AfterUpdate()
  3. Dim varProdName, varProdCost, varWeight As Variant
  4.     varProdName = DLookup("ProdName", "Products", "ProdID =[ProdID] ")
  5.     varProdCost = DLookup("ProdCost", "Products", "ProdID =[ProdID] ")
  6.     varWeight = DLookup("weight", "Products", "ProdID =[ProdID] ")
  7.  
  8.     If (Not IsNull(varProdName)) Then Me![ProdName] = varProdName
  9.     If (Not IsNull(varProdCost)) Then Me![ProdCost] = varProdCost
  10.     If (Not IsNull(varWeight)) Then Me![Weight] = varWeight
Feb 27 '07 #1
1 1725
MMcCarthy
14,534 Recognized Expert Moderator MVP
Change code to ...

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub ProdID_AfterUpdate()
  3. Dim varProdName, varProdCost, varWeight As Variant
  4.  
  5.     varProdName = DLookup("ProdName", "Products", "ProdID=" & Me.ProdID)
  6.     varProdCost = DLookup("ProdCost", "Products", "ProdID=" & Me.ProdID)
  7.     varWeight = DLookup("weight", "Products", "ProdID=" & Me.ProdID)
  8.  
  9.     If (Not IsNull(varProdName)) Then Me![ProdName] = varProdName
  10.     If (Not IsNull(varProdCost)) Then Me![ProdCost] = varProdCost
  11.     If (Not IsNull(varWeight)) Then Me![Weight] = varWeight
  12.  
Feb 27 '07 #2

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

Similar topics

1
18515
by: shortbackandsides.no | last post by:
I'm having a lot of difficulty trying to persuade the Google toolbar autofill to act consistently, for example ======================= <html><head> <title>autofill test</title> </head><body>...
0
4247
by: David Portabella | last post by:
Hello, I am a doing a survey about Autofill Web Forms softwares. Usually, they all collect information of the user once during the set-up phase (user knowledge base). Then, when the user...
0
2289
by: Ray Holtz | last post by:
Is it possible to autofill a field based on what is entered into another field in a form? My form has an employee field, and department field. In an Items Table, I have fields FldEmployee, and...
1
2107
by: Nick J | last post by:
Hi, I remember at one point access would autofill a text box when filtering by form, Like for example as I would type it would come up with matching records, similar to AutoComplete in Internet...
10
2805
by: sandraz444 | last post by:
I have an expression in the query under my form to autofill the date under a certain condition but it wont write to the underlying table?? The date shows in the form but not the table. Does anyone...
0
2042
by: Randy | last post by:
Hi, I have some comboboxes that are created dynamically at run time based on user actions. I found a procedure on a message board to autofill the combobox text from the dataview that the...
0
1131
by: KIBO | last post by:
Hi, I'm a non-windows programmer, and have been asked about creating modyifying a table to include autofill capability much like that of Excel. That is type in 1, 2, select those cells and drag...
14
3458
by: 794613 | last post by:
Hello, I'm very new to access (about a week I've been working on this database) and am trying to make a database to track jobs for a company I work for. I've got the layout side of access laid out...
1
2102
by: Dean0621 | last post by:
Good morning folks, as with most people on here with their first time question, I have been working on this issue for nearly two weeks, doing some searching on this forum and the internet to assist...
0
7205
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
7093
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
7287
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
7353
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...
1
7011
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...
1
5023
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...
0
3180
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...
0
1521
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 ...
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.