473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Autofill info in Subform

I have a Form (frmsOrders) with a subform (frmOrdersDetails 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_AfterUpdate()
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 5774
puppydogbuddy
1,923 Expert 1GB
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
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 Expert 1GB
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....therefore 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
Got it!

Thanks
Mary
Apr 1 '08 #5

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

Similar topics

1
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>...
2
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...
1
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...
3
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: ...
8
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...
8
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...
13
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...
1
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...
2
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....
0
BarryA
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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
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...
0
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...
0
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...
0
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,...

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.