473,657 Members | 2,477 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 1736
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
18526
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> <form method="POST" action=""> 1 email <input type="text" name="email"><br> 2 name <input type="text" name="name"> <br>
0
4257
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 navigates to a web form, the autofill software can automatically partially fill the form. The solution can be mostly differenciated by its intelligence algorithm for matching between the
0
2298
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 FldDepartment. FldEmployee is looked up from an TblEmployee Table which also has fields FldEmployee and FldDepartment. This FldDepartment field is looked up from a TblDepartment table that just has FldDepartments. I hope I explained that OK The...
1
2115
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 Explorer, I now have nearly 4,000 records, is this the reason why it does not perform this function anymore? Thanks...
10
2837
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 know a solution for this? Thanks!
0
2051
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 comboboxes are bound to. It works perfectly on the comboboxes that I have created at design time, but the ones that I create runtime behave differently. The problem is that when the user tabs onto the combobox, the box stays blank, which is fine. ...
0
1137
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 using the 'autofill' black square, and end up with 3, 4, 5, etc. It is slighlty more complex than the example and may have a mixture of alpha and numerals, but nothing more complex than Excel currently can handle. There are two options I am looking...
14
3480
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 fairly well, but I'm having trouble with the programming side of Access. I've got one main table that the information will be pulling from called tblCustomers. This contains the information that I want to display on the form I've attached. Basically...
1
2126
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 me. Here are the facts: I have one table PERSONS that is created from an external program that contains personal data on individuals including cfirstname, clastname, caddress1, czipcode, ccity, cstate, cphonenumber, cbirthdate, and so on. I...
0
8325
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
8844
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
8742
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 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...
1
8518
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,...
0
8621
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
4173
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
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
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...

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.