Topic: combobox questions

i have a couple of questions about the combo box.

1. when i use multiple fields they are run together. is ther a way to put spaces between them and control how many spaces.

2. how to i reference the different fields in the same combobox. ie. combobox1.???.value:=something

3 this is a long one. i have a pool of a-z and a combobox with choices A,B,C. i choose A. I have some more comboboxes with choices a-z. i pick a-d for the firs and e-j for the second etc. the question is when i go to another form how do i get the comboboxes holding partial alphabets for a to show as partial alphabets and not the whole a-z for each combobox.

Re: combobox questions

Hello Lee,
1.  In the combobox object properties for FIELDNAME, you enclose each of the fieldnames you want to display in curly brackets - {} and then insert as many spaces (or literals) as you want.  For example
{name},   {zip} / ({phone})   will give you - Lee,  01234 / (012345678)
2.  Displaying multiple fields in the combobox doesn't mean that this is how they are stored in the database - it is simply how you've asked for them to display on the form.  So, If I understand your question, you would need to reference whichever field you're interested in with an SQLEXECUTE statement in your script.  For example
sqlexecute('select name from customers where id ='+ inttostr(form1.combobox1.dbitemid)); or
sqlexecute('select zip from customers where id ='+ inttostr(form1.combobox1.dbitemid));
3.  Not quite sure what you're trying to do here - can you give us a bit more info - or some screenshots?
Derek.

Re: combobox questions

hi derek

thanks for the help again.
1. works great, just what i needed.

2. thats way beyond my knowledge of sql. in my quest for learning sql i did come across this nice site: http://www.fincher.org/tips/General/SQL.shtml. samples of about every sql command.

3. relates to my billiards project. i have set up several teams so my top combobox contains that list. i pick one of those teams. under that i have 10 comboboxes each have the full list of players available. i pick one player from the list for each box. now i have a team with 10 players assigned to it. when i go to fill in a blank scoresheet with the same combobox arrangement (team but only 4 players), i can pick the right team from the team box but the players dont follow. when i go topic the team member that should be assigned to that team the  full list of players not just the 10 assigne to the team.

lee

Re: combobox questions

Hello Lee,
On Point 3), it sounds like you need to set up your teams and players and assign your 10 players to each team (as you are already doing).
Then on the scoresheet, select your team from the 'team' combobox and then make the 'team' combobox a parent of the 4 'player' comboboxes using the 'parent' combobox object property.  Hope that makes sense.
I've knocked up a small project to give you an idea how you might tackle it (sorry about the rubbish test data!).
Hope it helps,
Derek.

Post's attachments

Attachment icon lhimescombobox.zip 340.39 kb, 506 downloads since 2016-05-02 

Re: combobox questions

hi Derek

coldnt get it to work. i just got an empty list for the player combobox. tried to play around and get your configuration to work for me but seem to be missing something  enclosed is a very simplified version of the way i am doing things. maybe that will help.
thanks again

lee

Post's attachments

Attachment icon My Sample.zip 8.09 kb, 471 downloads since 2016-05-02 

Re: combobox questions

Hello Lee,
The problem is with the structure of your teamplayers table;  you are trying to hold all 10 players on only one row;  this means that when you use the comboboxes, you will only ever see that 1 row of data.  Comboboxes are used to choose a row from a related table, not to choose a specific field from within a row.
The best way around it is to restructure your teamplayers table with (in your example) just 2 fields - the ID of the link to the teams table and the ID of the link to the players table.   You would then create 10 rows of data (one per player) for each team.
Then, on your scorecard form, you can use the combobox dropdowns with parent comboboxes pretty much as you were trying to do to select your 4 players from the 10 assigned to each team.
I've attached your project with the suggested changes - but as always, there are other options and maybe someone else might see a different way to do it. 
BTW, I've left the grid on the scorecard form simply because it's easier to check that the 4 players you've picked have been saved to the table correctly.
Derek.

Post's attachments

Attachment icon My Sample2.zip 341.56 kb, 483 downloads since 2016-05-03 

Re: combobox questions

hi Derek

i understand what you are saying. i'm not quite sure i understand what all you did to fix it. it does work and i thank you for that. now back to beating my head against the wall trying to figure out how to do the next thing with this little project. thanks again

lee

Re: combobox questions

hello again Derek


i think i figured out how to do the visitor team but i cant get any of the information to show up in the tablegrid to make sure i am actually getting two different  teams saved. i have been playing aroung with this fora few da getting nowhere.

lee

Post's attachments

Attachment icon My Sample2.zip 11.56 kb, 450 downloads since 2016-05-13 

Re: combobox questions

Hello Lee,
There were 2 main things I noticed when I looked at your latest version.
1.  Comboboxes 6,7,8,9 and 10 ( the  visiting team and the visiting team players) hadn't been added to the 'save' button on the 'scorecard' form.
2.  The visiting team and visiting team players were selected for display on scorecard.tablegrid1 but not on the grid associated with scorecard.button4 (the 'search' button).  When you are using a 'search' button, the search grid always takes precedence.
The most foolproof way to check if everything is being saved, is to double-click on the sqlite.db file and look at the raw data using something like SQLiteStudio.
I've attached your project back so you can see the changes and check if it's doing what you want now.
Regards,
Derek

Post's attachments

Attachment icon My Sample2 changed.zip 342.1 kb, 487 downloads since 2016-05-16 

Re: combobox questions

Hi Derek

Thanks again. i just downloaded the file and will check it out. i was wondering if ou would have any recommendations on the best/easiest way to attack the math stuff i need to do on this. team ran, team total score for season, win percent, player games played, games won/lost, mvp points, etc. as always, look forward to hearing from you.

lee

Re: combobox questions

hello again Derek

just chedked out the dl. its close but there is a problem. no what team i choose as the visitor team, the same team name shows up.'fire ballz'. the player show up as the right players  for the team i pick..

lee

Re: combobox questions

i can get the teams to show up by adding a teams1 to the scorecard and teamplayers tables but cant get the team members to show up on the visitor side of the scorecard. tried every way i could think of for the last 30 or so hours. could use some help please.
thanks

lee

Re: combobox questions

Hello Lee,
Had a quick look and came up against the same problem.  You can either have
1.  the parent comboboxes working as you want but the grid doesn't display the away team properly (and then the data gets messed up if you do 'edits').
2.  the grid displays correctly and the integrity of the data is maintained when editing BUT the parent comboboxes don't work.
I believe it's because MVD is treating the 'home' parent combobox and the 'visitor' parent combobox as the same field of data when it comes to saving the record.  I'm certainly not saying it's a bug - it's more to do with how you want the form to work.  If the 'home' team and the 'away' team were added/edited on separate forms, I think it would be okay but I appreciate that's not how you'd want it working in the 'real world'.
The only compromise I could think of, which may be acceptable, is as follows;
1.  forget about using parent comboboxes
2.  in the home and visiting player comboboxes, display not just the player name but the team name and the player name together (so there is a visual check that the correct player is being chosen). 
To simplify this, I'd sort the home and visiting player comboboxes by team so that they are all grouped together.  Have a look at the attached screenshot if you're not sure how to do that (sorting the combobox by team is a small hack).
One other thing I noticed was you'd scripted for the 'search' button to be automatically 'clicked' when an item in the combobox is selected;  I'm not sure if you're aware but there is the 'incremental search' option (one of the object properties) that already does this for you (it's more obvious on an 'edit field' rather than a 'combobox' - see the second screenshot). 
Hope some of this helps to move things on a bit.  You could certainly have picked an easier project as your first one, but I guess any projects you do after this will seem a breeze in comparison - LOL!
Derek.

Post's attachments

Attachment icon My Sample2 changed.zip 584.53 kb, 528 downloads since 2016-05-19 

Re: combobox questions

Hi,
I have a project with a combobox that allow users to set record type!
I don't want to have an extra table for record types! because I have only 2 or 3 types and those types never change!
So how can I fill a combobox values without using tables ?

Thanks a lot smile

Re: combobox questions

hello again Derek

its nice to know that there wasnt a solution i was missing for lack of knowledge.  i will have to think about your solution to decide which way i want to go with it.

the search button got put in by someone else. i dont use it so i just didnt pay any attention to it.

i did do an easier project acoupleof years ago. i did a magazine cataloging program that i thought came out fairly decent.  otherwise i dont usually go for easy first, i justjumt in with both feet.  been working on a visual basic program  on and off for about 15 years. starting to get close to the end of it when i was asked to try this one.

thanks again for the help

lee

Re: combobox questions

Dimitry
I currently use the version 1.45, and in a form where I displays a list of records in a TableGrid based on selection using ComboBox, creating a new record invoke a form for data entry, and I want to recover data from the ComboBox to place them in their respective TextBox on the new form, is this possible?

Much I appreciate your help

Re: combobox questions

gamalier_ramirez wrote:

Dimitry
I currently use the version 1.45, and in a form where I displays a list of records in a TableGrid based on selection using ComboBox, creating a new record invoke a form for data entry, and I want to recover data from the ComboBox to place them in their respective TextBox on the new form, is this possible?

Much I appreciate your help

Hello,


example:

procedure frmDataEntryForm_OnShow (Sender: string; Action: string);
begin
    if Action='NewRecord' then frmDataEntryForm.Edit1.Text := Form1.ComboBox1.Text;
end;
Dmitry.