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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autoupdate fields after combo box select

Status
Not open for further replies.
Apr 26, 2004
87
US
I have a combo box named CompanyName.
Control Source = CompanyName
Row Source Type = Table/Query
Row Source = SELECT Customers.CompanyName, Customers.ContactFirstName, Customers.ContactLastName, Customers.Facility, Customers.FacilityContact, Customers.FacilyPhone, Customers.PhoneNumber, Customers.Extension FROM Customers;

I am trying to choose a company and have other fields auto populate. It seems to be doing really weird things right now, some update some don't..but then the ones that update get changed to the company name. Here is what i have on my after_Update

Private Sub CompanyName_AfterUpdate()
ContactFirstName = CompanyName.Column(1)
ContactLastName = CompanyName.Column(1)
facilityContact = CompanyName.Column(1)
facilityPhone = CompanyName.Column(1)
PhoneNumber = CompanyName.Column(1)
Extension = CompanyName.Column(1)
FACILITY = CompanyName.Column(1)
End Sub

Can Someone Help me out


MCSE 2K - MCSA 2K - NET+ - A+

Paul..
 
Seems you forget to use the right column number :
ContactFirstName = CompanyName.Column(1)
ContactLastName = CompanyName.Column(2)
facilityContact = CompanyName.Column(4)
facilityPhone = CompanyName.Column(5)
PhoneNumber = CompanyName.Column(6)
Extension = CompanyName.Column(7)
FACILITY = CompanyName.Column(3)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi,
Instead of using the after_update event try using the on_change event. Are you using the after_update for a reason?
 
I made both changes. But the only thing that changes correclty is the first entry
ContactFirstName = CompanyName.Column(1)
Nothing else changes correctly.??

MCSE 2K - MCSA 2K - NET+ - A+

Paul..
 
what exactly does the column(#) do? is this trying to pull info based on the column number in the table? or the select query? or is it just an identifier?

MCSE 2K - MCSA 2K - NET+ - A+

Paul..
 
The column number refers to the columns in your combo box (starting with column 0). Make sure you're using the right control names.
ContactLastName = CompanyName.Column(2)
means "take the value from the 3rd column of the control named 'CompanyName' and place it in the control named 'ContactLastName'."


Randy
 
I have a question. I tried to do this for something I'm working on. It works but.. I have a form that lets you enter multiple entries at once, and everytime I choose the first value for the first entry, the special value changes for all the entries. EG:

Form looks like this:

Client Car Comments
-----------------------
Smith 1 blah blah blah
Roger 2 more comments
Carmen 3 comments for this

You should be able to choose any client and enter any comments. The car column is simply to make sure you chose the right client from the combo box without having to look everytime. Right now if I choose Smith, all three entries would change to show cars as 1. How do I get it to ONLY change the field for smith??

[cat2] *Suzanne* [elephant2]
[wavey] [wiggle]
 
Yeah mine is doing some weird stuff also. The first column changes fine ContactFirstName but the combo box values keep resetting and overwrite eachother. Like if i have company1,company2,company3,company4. and im browsing back in forth with the combo box between companies the only field that changes is the contactfirstname..but after i close and reopen the form a lot of the companies get reset to company1. so it will show company1,company1,company1,company3,company4. I can't pin point it and see what is going wrong.?

MCSE 2K - MCSA 2K - NET+ - A+

Paul..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top