Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box to populate data in text boxes 2

Status
Not open for further replies.

monkeyrubber

IS-IT--Management
Sep 15, 2006
3
US
Okay, I'm a little out of my element. I'm a Java developer, but my boss has asked me to help him with a MS Access problem, and I'm dumbfounded by the Access form builder.

Here's the problem:
My boss has a a combobox, which is bounded against a datasource. That works. He wants the combobox to automatically drive the population of a series of textboxes.

Basically the user selects a user in the combobox, and then the user's data is automatically populated in a bunch of textboxes

I'm lost. Please help.

Thanks,

monkeyrubber
Because Han Shoots First
 
Sounds like the text box is being designed to look up values in existing records and then use those to fill in a record. If this is the case, take a look at the Northwind sample database (Help>Sample Databases>Northwind) and open the Orders form.

Does it behave the way you would like? If so, and you need help customizing the code, let me know.

Tom

Born once die twice; born twice die once.
 
Agreed, this is exactly what I'm trying to do, however I'm having a hard time getting it to work in my boss' Access app.

I think I'm having a fundamental difficulty understanding the Access paradigm. I'm used to working with recordsets, DAOs and SQL, but I'm not able to find any in the Northwind example. Is there some abstracted DAO some where that I can simply pass my SQL against?

Here's the code from the Northwind sample:
Me!ShipName = Me![CustomerID].Column(1)
Me!ShipAddress = Me!Address
Me!ShipCity = Me!City
Me!ShipRegion = Me!Region
Me!ShipPostalCode = Me!PostalCode
Me!ShipCountry = Me!Country

1. Does Me has a recordset intrinsicly available?
2. If it does, is this were Address, City, Region, etc. are coming from?
3. How do I pass my selected value from the combobox to the rs to get it to return the appropriate columns?


Thanks,

monkeyrubber
Because Han Shoots First
 
Hi there!
The Orders form gets its records from the following SQL:
Code:
SELECT Orders.OrderID, Orders.CustomerID, Orders.EmployeeID, Orders.OrderDate, Orders.RequiredDate, Orders.ShippedDate, Orders.ShipVia, Orders.Freight, Orders.ShipName, Orders.ShipAddress, Orders.ShipCity, Orders.ShipRegion, Orders.ShipPostalCode, Orders.ShipCountry, Customers.CompanyName, Customers.Address, Customers.City, Customers.Region, Customers.PostalCode, Customers.Country
FROM Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID;

The Me keyword in this context refers to the order form, and the [!]![/!] refers to the field in the query which feeds the form.

What you will need to do is build the query which displays the records you want. From there, here's how to interpret the above:

Me!ShipName (control receiving the data) Me![CustomerID].Column(1) (field from the query containing the value which will populate the ShipName)

Hope this helps.

Tom


Born once die twice; born twice die once.
 
Hi Monkeyrubber,
There are (basically) two ways you can use a combox. One is where it filters the forms recordset showing the record selected in the combox. In this case the textboxes are bound fields (bound to a recordsource)

The second one is where the combox populates unbound textboxes on the form. In that case the data comes from the combox-source itself. Say your combox (cboCustomer) has three fields:
1. CustomerID
2. CustomerName
3. CustomerAge

And, say your form has two unbound textboxes:
1. txtCustomerName
2. txtCustomerAge

You could now populate the two textboxes by setting some code in the afterupdate-event of the combox using the column-property, like:

Me.txtCustomerName = Me.cboCustomer.Column(1)
Me.txtCustomerAge = Me.cboCustomer.Column(2)

Note: the first field in the combox is referenced as Column(0)






Pampers [afro]
Keeping it simple can be very difficult
 
Tom and Pampers,

Thanks for helping. I got it working. Pampers your tips on how the rs is tied to the the combobox was the breakthrough.

Thanks again for all your help!


Thanks,

monkeyrubber
Because Han Shoots First
 
I need to create a loop where a user puts in a value on a form. The form would then look up a record from a table or from an import table and then append that record to a new table that amount of times. So, if the multiply number was 5, it would look up the record and then append it 5 times to the new table. Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top