473,804 Members | 3,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Autofill info in Subform

30 New Member
I have a Form (frmsOrders) with a subform (frmOrdersDetai ls Subform). I am trying to automatically fill in the Item Description, Unit and Price when choosing the SKU# from a combobox. I have this working perfectly for the Customer and Address info in the main part of the form, but the same syntax does not work in the Subform.

I have read the 'How to refer to items in Subform' article in the How To section and many posts on the subject. I also had success with this in the past, but it is just not working this time. I'm thinking it had something to do with the way my forms were linked and the relationship I had. I fixed all of those things and the form is working the way I want except for this one thing.

This is what I have in the After Update Event in the Name combobox on the main form and it works fine:

Private Sub Name_AfterUpdat e()
Me![Rank] = Me![Name].Column(2)
Me![Address1] = Me![Name].Column(3)
Me![Address2] = Me![Name].Column(4)
Me![City] = Me![Name].Column(5)
Me![State] = Me![Name].Column(6)
Me![ZipCode] = Me![Name].Column(7)
Me![CAPID] = Me![Name].Column(8)
End Sub

I changed the code in the After Update Event in the SKU combobox on the subform to this, but it is not working.

Private Sub SKU_AfterUpdate ()
Me![frmOrderDetails Subform].Form![Item Description] = Me![SKU].Column(2)
Me![frmOrderDetails Subform].Form![Unit] = Me![SKU].Column(3)
Me![frmOrderDetails Subform].Form![Price] = Me![SKU].Column(4)
End Sub

Any help would be appreciated.
Thanks
Mar 30 '08 #1
4 5796
puppydogbuddy
1,923 Recognized Expert Top Contributor
If the SKU combobox and the autofill fields are both on the subform, try changing this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub SKU_AfterUpdate()
  2. Me![frmOrderDetails Subform].Form![Item Description] = Me![SKU].Column(2)
  3. Me![frmOrderDetails Subform].Form![Unit] = Me![SKU].Column(3)
  4. Me![frmOrderDetails Subform].Form![Price] = Me![SKU].Column(4)
  5. End Sub
To this

Expand|Select|Wrap|Line Numbers
  1. Private Sub SKU_AfterUpdate()
  2. Me![Item Description].Value = Me![SKU].Column(2)
  3. Me![Unit].Value = Me![SKU].Column(3)
  4. Me![Price].Value = Me![SKU].Column(4)
  5. End Sub

I am assuming that you are aware that column indexes in Access start with 0 for the first column on the left, then 1 for the next column and so forth.....so if the SKU is the first column of your combobox and description is the next column, the column index for the Description column would be 1, not 2 as shown below:

Me![Item Description].Value = Me![SKU].Column(1)

You may have already taken this into consideration; this is just in case you were not aware of how the column indexes are derived.
Mar 30 '08 #2
mgstlucia
30 New Member
Thank You. That worked but I'd like to understand why.

The problem now is that when I choose a 2nd and 3rd SKU#, the ItemDescription ,etc. updates all of the items on the subform with the current one. I'm assuming that it is because the ItemDescription , Unit and Price are unbound controls. When I try to set the controlsource of the control the dropdown box only shows the fields for the OrderDetails table which is the recordsource of the subform. So, I tried to use the Expression Builder to point it to the Products table/ItemDescription field, but ended up with #Name? in the control when I open the form. This is what the controlsource looked like when I used the Expression Builder: [tblProducts]![Item Description].

I was aware of how the Combobox columns are indexed. I have a hidden column which is column 0, SKU# is column 1.

What should I do next?
Thanks
Mar 30 '08 #3
puppydogbuddy
1,923 Recognized Expert Top Contributor
Thank You. That worked but I'd like to understand why.

The problem now is that when I choose a 2nd and 3rd SKU#, the ItemDescription ,etc. updates all of the items on the subform with the current one. I'm assuming that it is because the ItemDescription , Unit and Price are unbound controls. When I try to set the controlsource of the control the dropdown box only shows the fields for the OrderDetails table which is the recordsource of the subform. So, I tried to use the Expression Builder to point it to the Products table/ItemDescription field, but ended up with #Name? in the control when I open the form. This is what the controlsource looked like when I used the Expression Builder: [tblProducts]![Item Description].

I was aware of how the Combobox columns are indexed. I have a hidden column which is column 0, SKU# is column 1.

What should I do next?
Thanks

1. To answer your question as to why your syntax did not work: You used the "Me" operator as if Me was the main form, but the combobox and the autofill controls are both on the subform and the code would be executed from the subform....ther efore Me in this case is the subform, not the Main form.

2.Yes, your problem with the SKU overlays was due to the fact that the subform is a continuous form, and the ItemDescription , Unit and Price controls were unbound. However, the combobox should be left unbound.

3. What you do next......
a. be sure the record source of the main form is set to the Table that has the fields that any controls are bound to (if any).
b. be sure the record source of the subform is set to the table that has the fields that all the subform controls (excluding the combobox) will be bound to.
c. bind (set the control source) of all the controls (except for the combobox) to the controls underlying fields.
c.the subform combobox is to be left unbound, but you need to set its row source to a query that outputs the fields that you want to display from both tables.
Mar 30 '08 #4
mgstlucia
30 New Member
Got it!

Thanks
Mary
Apr 1 '08 #5

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

Similar topics

1
18534
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>
2
2712
by: Andre Ranieri | last post by:
I'm retouching our corporate web site that, among other things, allows customers to log in and pay their invoices online. I noticed that on the checkout page, the credit card number textbox autofills with past entries for that textbox. My development workstation has the Google Toolbar installed; I'm not sure whether the autofill functionality is native to the browser or coming from the Google Toolbar. In either case, is there any way...
1
4267
by: Stephen D Cook | last post by:
I have a search form with a query-linked subform. One of the fields in the subform are date fields. Is there a way to autopopulate the DateFilled field when the person enters the field? I need this to be code which is entered into the form, rather than as a property of the field in the table because there is other data which is entered before. This data is entered in at a later date.
3
1399
by: StuckAndNoClue | last post by:
I've searched through some of the answers on the forum regarding autofill but I can't work out how to do it for my database. I have two tables 1. Members info, containing the following fields: a. Member ID (primary) b. Division that the member belongs in c. Address d. Names 2. Division Night info containing the following fields:
8
2370
by: tess | last post by:
I have: table 1 - tblLeadInfo which includes a salesman ID field table 2 - tbllkpSalesman with all zips in the state and a Salesman assigned to that area. I have a form based on table #1 When I enter the zip code in the form, I'd like the Salesman ID field in tblLeadInfo to fill in accordingly and also show the salesman name on the form. I'm sure this is simple, I just can't seem to get it straight in my
8
1965
by: Christina123 | last post by:
Currently working with Microsoft Office 2000 and whatever version of Access came with that. I am developing a database to track the comings and goings of shared tools. Everything works splendidly except I have printing issues, primarily I have no idea what I am doing. I have a form that contains the date and the info of the person doing the ordering as well as a subform that has the serial number of the part, the description and storage...
13
6231
by: BASSPU03 | last post by:
Hello, folks. This is my first post and I only began to work extensively with Access about 3 weeks ago. I'm running Access 2003 on Windows XP. I'd like a textbox in subform2 to reflect the value chosen from a combobox in subform1. FYI: Both of these subforms are linked to a main form with five fields (AutoNumber, Quantity, Resource, Type, and General Description; "AutoNumber" is the primary key). My main form lists a resource (e.g....
1
2175
by: dvorasnell | last post by:
Hello, I have a fairly simple database. In this dbase, there is a subform which basically holds menu values for the records. These values serve as the "notes" for each record. OK, I find that I am typing a rather long string in many "notes" section of the subform. Rather than have to type this over and over again, I would like to automate this procedure. So I have tried to create an "Event Procedure" to accomplish this, but so far, the...
2
4258
rsmccli
by: rsmccli | last post by:
Access 2002 Hi, I have a number of comboboxes/textboxes in the header of a form that the user selects values from. These comboboxes/textboxes correspond to controls in a datasheet view subform. When a new record is created in the subform I want these values to automatically write to the new record in the subform. Right now I have this autofill procedure running on the AfterInsert event of the subform. It works well, except for the fact...
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9584
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,...
1
10323
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
9160
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
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();...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
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
2
3822
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.