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

Combo Box populates other fields on form

Status
Not open for further replies.

backer

Technical User
Apr 13, 2001
24
US
I have a table with 3 fields: ContName, ContNo and CM. On a form, from a Combo Box, I would like to choose the ContNo which fills in the ContNo field and also automatically fills in the ContName and CM in the ContName and CM fields on the form. I did this a few years ago, but I forgot how to do it. Please let me know how to do this without code or macros.
 
if you have your wizards installed and on when you place the combo box it should guide you throuhg the setup for this

Dave
ToeShot@Hotmail.com
Today Is Tomorrows Yesterday. So Why Wait
 
Isn't this for just entering the information in one field. How does this enter information in other fields at the same time?
 
What happens with the wizard is that it puts cdoe into the form on the AfterUpdate event of the combobox. It's looks like this

Private Sub NameLookup_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ContactID] = " & Str(Me![NameLookup])
Me.Bookmark = rs.Bookmark
End Sub

where NameLookup is the name of the combobox, it takes and sets a variable to your current recordset then it finds a particular record from that recordset, in the bacground with the criteria specified then it sets your current bookmark to the record just found by your criteria. This updates all the fields in the records to the one you are searching for.

As I had mention though. if you do not want to code the wizard will do this for you, if you follow it through.

Dave
ToeShot@Hotmail.com
Today Is Tomorrows Yesterday. So Why Wait
 
I've always used the .column property to populate other fields

Your combo box has three columns (0), (1) & (2)

On the afterupdate of the Combo box you could have this code:

Code:
Sub MyCombo_Afterupdate()

   Me.FieldOne = MyCombo.Column(1)
   Me.FieldTwo = MyCombo.Column(2)

End Sub

If the fields don't update you can always add the line
Code:
 Me.Refresh
birklea

birklea ~©¿©~ <><
Dim objJedi as Jedi.Knight
Set objJedi[skyWalker].Aniken = FatherOf(useThe.Force(objJedi[skyWalker].luke))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top