Source language: Translate to:

Bound ComboBox Question

Questions about our Advanced Database plug-in

Moderator: Neosoft Support

Bound ComboBox Question

Postby weedbrok » Sun Jan 04, 2009 5:32 am

Hi all,

I am using an Access Dbase with DbPro and am struggling with the following. Any advise would be appreciated.
1. I have a category table with AutoCategory_ID number and category name
2. I have an item table that stores a selected AutoCategory_ID as the detail table for the category table.
3. I can fill the combo box from the database with the category names, and set the variable to write and store to the item table, but cannot seem to show the Category name but store the AutoCategory_ID.

I realize that in the data grid view that this can be done, but the grid only shows the AutoCategory_ID until clicked on to expand the category name.
Not as user friendly as I would like.

Ideally I would like to
A: See the category name in the combo and store the AutoCategory_ID when selected
B: Have the form show the Category name when people are looking at next - previous or searched records.

Thanks in advance
Posts: 3
Joined: Fri Jan 02, 2009 8:51 pm

Postby smartmedia » Sun Jan 04, 2009 6:35 am


Try to use this.
dbpFieldToVar "DatabaseName" "TableName" "FieldName" "[CategoryList]" "Delimiter=[#13];SkipBlanks=Yes;NoDuplicates=Yes"
With this you get all the Categories in a variable called [CategoryList].
Put this variable inside combobox List items
Now in combobox variable enter a variable, lets say [SelectedCategory]
Now goto combobox actions-->Selection Changed and write this:
dbpExecSQL "DatabaseName" "SELECT * FROM TableName WHERE FieldName='[SelectedCategory]';" ""
This one will return you only 1 record, the category you have selected and the id of the category. Keep in mind that if you have more than 1 records with the same category name is not going to work.
User avatar
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas

Postby weedbrok » Sun Jan 04, 2009 8:28 am

Thanks for the suggestion.

Have used your ideas and expanded them to get the ID into a variable by creating a temporary table that I can then post back into the database.

Code below works fine.
dbpExecSQL "inventory" "SELECT Location_Room_ID FROM tbl_Location_room WHERE Location_Name='[SelectedLocation]';" "Temp1"
dbpOpenTable "inventory" "Temp1" ""
dbpFieldToVar "inventory" "Temp1" "Location_Room_ID" "[inventory.tbl_Item.Location_Room_ID]" ""

Next job is to then do something similar to above where I sql to retrieve the
location name from the current record showing by referencing the location_ID and then showing that in a text box. Should be able to rearrange combobox and textbox so it appears intuitive to the user.

Thanks heaps for the lead
Posts: 3
Joined: Fri Jan 02, 2009 8:51 pm

Return to NeoBookDBPro

Who is online

Users browsing this forum: No registered users and 2 guests