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

Maintaining sync with comboBox 1

Status
Not open for further replies.

Soundsmith

Programmer
Feb 21, 2001
84
US
I have a form supporting a query which is a simple "SELECT * from tblCodes". The primary key, code, is a comboBox, and I also have navigatioon buttons. I can code it so selecting a code via the combo box changes the display to show that row, but if I try to use the nav buttons, the comboBox value doesn't change (this is with the combobox unbound.) If I bind the combo to the field, the value changes in the current row of the query ratrher than selecting another row. How can I get them both to agree? David 'Dasher' Kempton
The Soundsmith
 
Hi!

Probably the simplest thing to do is the set the combo box off byitself, in the form header or in a rectangle control and identify it specifically for searching. Then add a textbox to your form which is bound to the key field and is with the rest of the controls for display purposes.

hth
Jeff Bridgham
P.S. There are numerous solutions to this type of problem, if this one doesn't seem to be the one you want let me know and we can try other things.
 
Thanks, Jeff. That's probably a workable solution, but not what I was hoping for. I have several of these "maintenance" tables, that contain codes with associated values used as lookup references. The other tables are fixed and unchanging, and thus don't need an add/edit/delete capability, but this table is subject to frequent alteration.

I'd like, if possible, a simple straight-ahead layout with the option to select a row by using either the combobox or the nav buttons, with the combo looking like just another element in the detail section. I thought I could use the current event to set the value in the comboBox if I used the nav buttons, but could not find a proper method. David 'Dasher' Kempton
The Soundsmith
 
Hi!

Well, you're right to keep the combo box unbound. Have you tried this code in the form's current event?

If ComboBoxName.Value <> Me!FieldName Then
ComboBoxName.Value = Me!FieldName
End If

Of course the FieldName is the name used in the table which corresponds to the value displayed by the combo box.

hth
Jeff Bridgham
 
Thanks, Jeff. I could swear that's what I did earlier (without the If, just 'cboCode=me.code)' and got duplicate key complaints!

Funny, I used to think I knew what I was doing! :-? David 'Dasher' Kempton
The Soundsmith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top