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

Autofill form fields

Status
Not open for further replies.

surfbum3000

Technical User
Aug 22, 2003
156
US
I created frmDataEntry and a combo box named cboCity. I also have a text box txtState that is autofilled from the cboCity
RecordSource =[cboCity].[column](2). This works. The problem is now I have a macro button to add new record. It adds all fields except the City and State. I want to update tblName with frmDataEntry using the following fields: LName, FName, Street, City, and State.

 
After several days of research, I finally solved the problem.
* Main table is tblPhonebook
* Also have tblLocDept with fields Dept and Location
* Make the form Record Source = tblPhonebook
* Create text box named txtLocation
* Create cboDept with

Record Source = SELECT DISTINCTROW [tblLocDept].[DeptLocID], [tblLocDept].[Dept], [tblLocDept].[Location] FROM [tblLocDept];

Bound column = 2

After Update = Private Sub cboDept_AfterUpdate()
Me.txtLocation = Me.cboDept.Column(2)
End Sub

Now when the Dept is selected on the form, the Location is automatically filled in.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top