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!

how to display 2 columns in combo... 1

Status
Not open for further replies.

adsfx

Programmer
Jun 4, 2003
237
GB
when my combo is populated, how do i get it to display the contents of two columns after a record has been selected?

also when a form adds to a combo' source, how do i get [on close] the combo to display the data that has just been entered in the form?

cheers MG
 
MG,

Try this. Say you have a table called Names, with fields
ID, Firstname, Secondname.

And you want to display both Firstname and Secondname together.

In your Row Source, Query builder show fields

ID and FullName: Names!Firstname & “, “ & Names!Secondname.

FullName contatanates the 2 strings. Then set up the column widths as you need them.

Hope that helps,

Maturi
 
Hi, adsfx,

I'll answer your 2nd question first. By the context of your question I'm assuming you have a 2nd form that adds data to your table, and after adding a new record and closing the form, you want that to be reflected in the combo on your first form. Is that about right? If so, create an event procedure in the On Close event of the 2nd form, something like this:

Code:
Forms!frmForm1!cboMyCombo.Requery

...substituting your form and field names as appropriate.

With your first question, I'm not quite sure what you're asking. Do you mean that you want the combo's display to change from displaying one column to display two columns after making a selection in the combo? Or do you want the info displayed elsewhere on the form?

Ken S.
 
Maturi - great stuff jus what i wanted
Eupher - have a requery in the onclose event of the form that adds to the combo-but does not set the recent data combos selection

thanx for yur time MG
 
Okay, I'm not sure of the exact sequence of events when the On Close event fires, so I don't know if the new record is being saved before the requery occurs. And if the requery occurs before the record is saved, the requery obviously accomplishes nothing. A couple of things to try:

1) In the On Close event procedure, add this line before the requery line:

Code:
DoCmd.RunCommand acCmdSaveRecord

2) An alternative (maybe a better choice) is to open the form in dialog mode and put your combo requery in the code on the *original* form immediately after the code that opens the new record form, i.e:

Code:
DoCmd.OpenForm "frmMyForm", , , , , acDialog
Me!cmbMyCombo.Requery

By opening the form in dialog mode, you suspend execution of the code until the form closes, so the requery would take place after the new record gets written.

HTH...

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top