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

Auto Populate a field

Status
Not open for further replies.

swan717

MIS
May 16, 2001
13
0
0
US
Hi:

I'm trying to create a database that will automatic populate a field when I enter something in the prior field. For example, the table has the following four columns: vendor, address, town, and date of service. The vendor's contact address and town will always be the same, so I want to have a combo box to list all of the vendors and then automatically populate the address and town fields. Is this possible?

Thanks in advance for your help!!!
 
Try the following code in the 'On_Change' event of the combo.....
[tt]
Dim db As Database
Dim rsVendor As Recordset

Set db = CurrentDb()
Set rsVendor = db.OpenRecordset("SELECT * FROM tblVendor WHERE vendorname = comboVendor.value;", dbopendynaset)

'(Replace: 'tblVendor' with your Vendor table name, 'vendorname' with your 'vendor fieldname, 'comboVendor' with your combo name).

txtAddress = rsVendor.address
txtTown = rsVendor.town

'(Replace: 'txtAddress' & 'txtTown' with the form textbox names)

rsVendor.Close
[/tt]

Kind regards,

Darrylle


"Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top