Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
steved157
Starting Member
8 Posts |
Posted - 2004-12-13 : 06:42:43
|
What is the syntax for referencing a combo box in a form in an MS Access SQL statement? This is what I have tried so far:SELECT [PS_WARD].[CODE], [PS_WARD].[DESCRIPTION] FROM [PS_WARD] WHERE [PS_WARD].[DISTRICT_ID] = [Forms]![ADDR_PRIM_STREET_Form]![DISTRICT_ID] |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-12-13 : 09:51:27
|
and when you tried that .... ???that is the format. i assume DistrictID is the name of the combo box? if not, then that's what needs to be there (remember-- the NAME of the combobox OBJECT, not the column it is bound to).ANd also ensure that the combo box, if it is a drop-down, is display possible values from a table of SQL statement, is set to return a value from the column you wish. i.e, you might be displaying a list of names, but you might want an "ID" to be returned. This is all under the "Data" tab for the properties of the combo box.- Jeff |
 |
|
steved157
Starting Member
8 Posts |
Posted - 2004-12-13 : 09:58:02
|
When I tried the above, the combo box that I wanted to reference the 'DISTRICT_ID' combo box (this IS the object name) was empty when the arrow was clicked on.I think I may have complicated things as each of the combo boxes displays more than one column, while storing just one.Any other ideas? |
 |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-12-13 : 10:06:18
|
did you requery the 2nd combo box?if combobox 1 is using combobox 2 as a filter, and combobox 2 changes, you must manually requery() combobox1 if you wish for the values to be synchronized.Again, it is not overcomplicating to display 1 column and store another, just make sure that you understand that concept and know for sure which is which ! when in doubt, close everything up, create a new simple form based on small table, and experiment. Don't learn stuff like this with actual data -- close it down and experiment in a small, simple environement.- Jeff |
 |
|
jhermiz
3564 Posts |
Posted - 2004-12-13 : 10:37:51
|
If your combo box has many columns associated with it...You will need to do:Forms!frmMain!cboCombo.Columns(0).Valueor replace 0 with the number / index you are looking for.Thanks,jon |
 |
|
steved157
Starting Member
8 Posts |
Posted - 2004-12-13 : 10:52:11
|
Thank you. Both of you.Much appreciated.Hopefully these will solve my problems.I am not risking actual databases with my experimentations, by the way. I'm working on a stand-alone for beta versions. |
 |
|
|
|
|
|
|