Source language: Translate to:

Search / Direct using ComboBox's

Questions about our Advanced Database plug-in

Moderator: Neosoft Support

Search / Direct using ComboBox's

Postby Trainman » Thu May 23, 2013 1:28 pm

Is this possible to create a search function with comboBox's and tables.

I have two ComboBox, one that Shows a list of six:
Junction
Station
Substaion
Siding
Tunnel
Hut

Then the second ComboBox is listing text file, but what I would like is to use tables from a database. The table have the first field as the name i.e. Junction and the second as Page.

What I would like is to be able select say Station in the first ComboBox and the second show a list of station, then press a button to change the map to the map with that station showing? I have amaged to get the second comboBox to show the first record with the table, and that as far as I have got.

Trainman
Trainman
 
Posts: 113
Joined: Fri Apr 01, 2005 10:21 am
Location: England

Re: Search / Direct using ComboBox's

Postby Gaev » Thu May 23, 2013 3:45 pm

Trainman:

In the Selection Changed section of the first Combo Box ...
Code: Select all
dbpQuery "yourDatabaseID" "yourTableNameHere" "yourFirstFieldNameHere = [ComboBox1]"
dbpFieldToVar "yourDatabaseID" "yourTableNameHere" "yourSecondFieldNameHere" "[ComboBox2List]" "Delimiter=[#13];SkipBlanks=Yes;NoDuplicates=Yes"

Note:

1) [ComboBox1] is assumed to be the Variable: (to store selected item) for your first Combo Box.

2) For your second Combo Box, specify [ComboBox2List] as the value for List Items


So, when you select Junction, Station etc. in the first Combo Box ... the second Combo Box will be populated with the "second field" from each record in the Table that 'has your first Combo Box selection' in its first field.

Hopefully, you know what to do with subsequent selections in the second Combo Box.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Search / Direct using ComboBox's

Postby Trainman » Fri May 24, 2013 11:38 am

Geav

Thanks for that information, I learn more from people with this forum, than book(most of the time).

I changed the code to
Code: Select all
dbpQuery "Map" "[ComboBox1]" "[ComboBox1] = [ComboBox1]"
    dbpFieldToVar "Map" "[ComboBox1]" "[ComboBox1]" "[ComboBox2List]" "Delimiter=[#13];SkipBlanks=Yes;NoDuplicates=Yes"


This work well, so that just leave me with the button to code.

Once again thank for your help

Trainman
Trainman
 
Posts: 113
Joined: Fri Apr 01, 2005 10:21 am
Location: England

Re: Search / Direct using ComboBox's

Postby Trainman » Mon May 27, 2013 3:27 pm

Geav

Sorry the Button is sending me mad. I understand that I need to get the Page field to a variable and that, will then allow me to change the image.
But my knowledge is very lacking and its well above my skills.

If you know where I can learn more that will help, can you please let me know.

Yours

Trainman :oops:
Trainman
 
Posts: 113
Joined: Fri Apr 01, 2005 10:21 am
Location: England

Re: Search / Direct using ComboBox's

Postby Gaev » Mon May 27, 2013 4:06 pm

Trainman:
Sorry the Button is sending me mad. I understand that I need to get the Page field to a variable and that, will then allow me to change the image.
But my knowledge is very lacking and its well above my skills.
I am not sure what you are trying to do with the "Button".

1) Please confirm that, using the code in my first response, you are able to populate the second Combo Box every time you/user selects an item in the first Combo Box ... and post actual examples of the items being populated.

2) Next, if you select one of these items in the second Combo Box, what exactly do you want the pub to do ? ... and where exactly does the Button and Image fit into this ?


Best to convey your needs with "real examples" e.g. ...

- when you click on item "abcd" in the second Combo Box, result should be "blah blah blah"

- when you click on the "Button", the Image Object should display "blah blah blah"
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Search / Direct using ComboBox's

Postby Trainman » Tue May 28, 2013 1:28 pm

Gaev

I'm creating a program that allows the user to look at some route map's and to use a search function to go to the page of the maps that hold the information he or she needs.

I have three methods of selecting the place on the route;

1: Via a Layered Map ( using tmPowerGUI plugin ).This can get you to the local area.

2: Via the ComboBox's and a button. If you know the name of the staion or other item i.e. tunnel, substation or Junction, you can go directly to it.

3: Via a Customwindow. If you are already looking at a section of a route and wish to go to a different route / location.

So if you want to go to a station on a route you select from ComboBox1 Station's and this with the code you posted, creates the list of station's in ComboBox2.
The Button will send you to the page that shows this part of the route. The database has a table named Station and two fields, one being the station and the other being the page number ( P102 ) that it's shown on.

Hope this explains.

Trainman
Trainman
 
Posts: 113
Joined: Fri Apr 01, 2005 10:21 am
Location: England

Re: Search / Direct using ComboBox's

Postby Gaev » Tue May 28, 2013 3:32 pm

Trainman:

Assuming that your second Combo Box's Variable: (to store selected item) is [ComboBox2] ... your Button's Click section code would be something like ...
Code: Select all
If "[ComboBox2]" "=" ""
   AlertBox "Dude" "Select a Station First"
   Return
EndIf

dbpQuery "yourDatabaseID" "Station" "Station = [ComboBox2]"
If "[yourDatabaseID.Station.$RecCount]" "=" "1"
   ... found the one matching record; which is also the current record
   ... so go to page in field called PageNumber
   GotoPage "[yourDatabaseID.Station.PageNumber]"
Else
   AlertBox "I am confused" "There are [yourDatabaseID.Station.$RecCount] matching records"
EndIf
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Search / Direct using ComboBox's

Postby Trainman » Thu May 30, 2013 2:57 am

Gaev
Thanks for responding.
I have used the code, with some changes but this still took most you yesterday to get it to work on the system.

Once again, Thank you for your help.

Trainman
Trainman
 
Posts: 113
Joined: Fri Apr 01, 2005 10:21 am
Location: England


Return to NeoBookDBPro

Who is online

Users browsing this forum: No registered users and 1 guest