Form Display

G

Guest

I have a form that has several combo boxes that are based off of Queries.
When they make a selection I want the combobox to display the name that is
selected but save the ID number. I know this is easy to do if the combo box
is linked to a table but I don't know how with a query.

Thanks in Advance.

Travis
 
P

Pieter Wijnen

same procedure

Pieter

Tdahlman said:
I have a form that has several combo boxes that are based off of Queries.
When they make a selection I want the combobox to display the name that is
selected but save the ID number. I know this is easy to do if the combo
box
is linked to a table but I don't know how with a query.

Thanks in Advance.

Travis
 
G

Guest

I can make it so that the list in the combo box displays both the ID and the
name, however once I select something it only displays the ID.
 
P

Pieter Wijnen

Which is how Combo's work!

You can however put an unbound Control on the Form
Control: ShowName
Enabled : yes or no
Locked: yes (if Enabled Else no)

And Then in the AfterUpdate Event of the Combo & under Form Current Event
(Event Procedures)

Private Sub cboMyCombo_AfterUpdate()
On Error Resume Next ' Ignore Errors
Me.ShowName.Value = Me.cboMyCombo.Column(1) ' Counts Columns From 0 in
Code
End Sub

Private Sub Form_Current()
On Error Resume Next ' Ignore Errors
cboMyCombo_AfterUpdate()
End If

HTH

Pieter

Normally you'd hide the first (zeroeth) column though by setting the Column
Width property
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top