Topic: Save Data from a Combobox

Hi All,
I have created a table containing names of US States. I have put a COMBOBOX on my Contacts form.  It shows the few states I have in my tblStates table.  But when I choose a State Name and SAVE the Contacts form, the State name is not saved in my Contacts Table.
-
I'm thinking it's probably something simple but so far I don't see it.
-
Note: That STATES button on my Start form is what I use to populate the State Names in the tblStates table.  I'll remove it (or hide it) once I get all the names in the tblStates table.
-
Attached is my sample file.
-
Any help will be appreciated.
-
Thanks
Frank

Post's attachments

Attachment icon RECORDS-TEST.zip 360.58 kb, 205 downloads since 2020-08-04 

Re: Save Data from a Combobox

Frank,
A relationship needs to be established between contacts and states so the combobox can be used as a lookup. Also, the tablegrid needed to bring in the state name from the state table. Fixed project is attached.

Post's attachments

Attachment icon RECORDS-TEST Fixed.zip 345.17 kb, 224 downloads since 2020-08-04 

Re: Save Data from a Combobox

EHW,
Your fix works perfectly.  I thought it might be something simple.
-
I think I did try setting a relationship from Contacts to States at one time, but I don't think I ever added the States Description to the Contacts tablegrid.  It looks like it took the combination of the 2 fixes to make it work.
-
I really appreciate you responding to this problem so quickly.
-
Knowing how to use a Combobox opens up some doors as I go forward with my program.
-
Thanks for your help smile
Frank

4 (edited by papafrankc 2020-08-04 19:03:33)

Re: Save Data from a Combobox

EHW,
As I said before, your solution works perfectly.
-
However, I went to the original file that I sent to you to make sure that I can implement the changes myself.  Since I will be doing this to more tables I want to make sure that I understand what I'm doing.
-
When I make your changes to my original project it doesn't work.  I'm gone over it many times and it still won't save the States Description. ???????? Obviously I'm missing something but I don't know what.
-
Here's the file with my attempt to implement the fix.
-
Thanks for your patience, Frank

Post's attachments

Attachment icon RECORDS-TEST-MINE.zip 360.79 kb, 199 downloads since 2020-08-04 

Re: Save Data from a Combobox

Frank,
You need to include the cboState field in the SAVE RECORD action of your SAVE button. It's an easy oversight even for veteran developers.

Re: Save Data from a Combobox

EHW,

I figured it would be something simple.  I made the change and all is well. 
-
I have noticed that sometimes when I make a change to my program it won't work because I missed a step somewhere.  I'm still not there yet where I remember to check all of the interconnected pieces, but I'm working on it.
-
The help provided by yourself and the others on the forum is really appreciated.
-
Thanks again, Frank

7 (edited by derek 2020-08-05 00:25:24)

Re: Save Data from a Combobox

Hi Frank,
Relationships between data tend to be either 'master/detail' (such as between your 'users' and 'contacts') or 'drop down lookups' (for want of a better expression, where you are just picking a value from a list - such as your 'states').
With 'dropdown lookups, the data tends to be static in nature and end-users only ever need to see it through comboboxes.  For that reason, you don't have to use discrete forms that are designed with your users in mind;  rather you can use a common form that holds ALL your look-up data and it can be maintained using editable tablegrids.
Using your example, you currently have 2 forms for your 'state' data.  If you were to also use look-ups (which would be my preference) for 'country', 'relationships' and 'male/female', that would then add up to 8 forms.  Throw in another few possible lookups ('salutations', 'zip codes', cities' etc) and the number of forms required quickly grows (not to mention the time it takes to create and test them).  All of this can be done using just one form and editable tablegrids.
Have a look at the attachment and the 'lookups' button on the 'start' form for an alternative way of doing things that is a lot quicker to develop).
One final suggestion is the use of 'parent' comboboxes (that you may or may not be aware of) - this is a way of linking comboboxes together.  For example, if you select 'Canada' as a country on your contacts form, you only want to see Canadian provinces and not US states etc. 
Obviously, you could extend this 'parent' combobox feature all the way down to countries > states > cities > zip codes etc.  It all depends how 'tight' you want to be with your data validation but it can make it a lot nicer for the end-user to only see relevant selections.
Maybe gives you some ideas.
Derek.

Post's attachments

Attachment icon RECORDS-TEST-MINE2.zip 347.06 kb, 263 downloads since 2020-08-05 

Re: Save Data from a Combobox

Derek,
Very nice, thanks.  Yes your example does give me some suggestions.
-
I had been thinking about Countries as a dropdown also but haven't gone there yet. 
-
At first I didn't see any way to add new data to each of the tables in your new frmLookUps form.  Then I tried to see if I could add data into the empty white box at the top of each tablegrid. Vola, that's how you do it.
-
But I didn't see how to add a new country to the state table. Then by trial and error I realized that you add the new Country first to the Country table, then you can choose the new country and put in the state info.  Very nice.
-
Everytime I try to do something new I'm impressed as to how automated MVD is.
-
And so far I've been able to build my program without any coding, except for the Calculated fields.
-
Thanks again for all your help,
Frank