earthQuake
earthQuake

Reputation: 106

Retrieving data from combo box based table

I have a database in MS Access with a table Main_Table where some fields are comboboxes, for example:

SELECT [Slave1_System].[ID], [Slave1_System].[System] FROM Slave1_System;)

I want to retrieve the value of the field "System" with id 2 and show it with MsgBox.

I have tried:

Set dbs = DAO.OpenDatabase("D:\test.mdb")
Set rs = dbs.OpenRecordset("SELECT * FROM main_table WHERE ID = 2")

MsgBox rs.Fields("System").Value

But it shows me ID of the row from Slave1_System table not the value that I want. How do I retrieve a value from combobox based field?

Upvotes: 1

Views: 140

Answers (1)

Monty Wild
Monty Wild

Reputation: 4001

Set the column width of the combo box columns before the one you want to show to 0.

Combo boxes display the value of the first non-0-width column corresponding to the table value.

Upvotes: 1

Related Questions