Populate table from multiple combo boxes

S

seth.northrop

Hi,

Thank you to those who replied to my previous post. I appreciate it.
I am now to the point where I simply need to write data from my form to
the table.

I have three tables: A, B, and C. C just contains aID and bID. A user
selects each of these fields from a combo box.

Now, I'd just like to create a submit button that does two things:

1) Verifies that both combo boxes have been selected
2) Populates table C with the data the user selected

Are there any resources out there that walk people through these, what
I assume, are fairly basic Access form tricks?

Thanks!
 
A

Albert D. Kallal

A few things about ms-access:
Are there any resources out there that walk people through these, what
I assume, are fairly basic Access form tricks?

Actually, they are not basic to ms-access. You have to remember, that
ms-access is a row orientated product, not a document based one.

So, for example, when you open a door on a car, the car does prompt to you

do you really want to open the door

While the above is laughable, it really is much the same in ms-access. If a
user is moving to the next record, why would they not want to save the data,
no more so then pulling the handle on a car door means that they want to
open the door. After you get into the cark, place the key in the ignition,
and turn it...do you want a prompt

do you want to start the car?

Really, this borders on the insane!!!

So, for the last 25 years, FoxPro, Knowledge Man, dbase II, dbase III dbase
etc. etc etc, FileMaker, DataEAse. (this list is HUGE), none of these
products EVER asked the user to save. It is *implied*. And, if you look at
the trends in Smartphone's, pda's, and even outlook, the trend is to IMPLY a
save.

Remember, even when you move a icon on top of your desk, you are actually
save the data (position) of the icon to a data file. However does windows
prompt you

do you want to save the position of the moved icon on your
desktop?


So, you will need to go through a paradigm change in how you design, and
approach software (you have to do it same it been done on eh desktop for the
last 25 years).

further, for some code examples, you can find a gold mine of examples code
here:

www.mvps.org/access

However, having given you that link, you REALLY REALLY want to get some type
of book, as ms-access has ABOUT DOUBLE the learning curve of VB for example
(the reason for this is that vb6 forms are simple, and ms-access ones are
data bound, and thus have more then 2 times the number of properties and
events).

Having explain the above, lets now work on your questions:
Thank you to those who replied to my previous post. I appreciate it.
I am now to the point where I simply need to write data from my form to
the table.

You don't need ANY code to write your data. If you make form "c" bound to
table c, then when you

a) close the form
b) move to another record
c) close ms-access

the record will be saved. As mentioned, the whole industry is (finally)
moving towards how a car door works, and this is if you try to open he door,
the door opens!!. If you move to another record, or close a form, then the
save is implied. If the user is not happy, then they must learn to used
edit->undo (in fact, they have to do the same thing in excel anyway...since,
if there are changes they want to keep, but the cell they just changed by
accident, the ONLY way to undo the change (without loosing all other
changes) is to go edit->undo. So, teach your users about edit->undo.

So, if the form c is bound to table c, then you don't need to do anything at
all, the data will be saved.

If you want the data to save by pressing a button, you can go

if me.dirty = true then

me.dirty = false

end if

So, if you are glutton for punishment, the above code will send the data to
the table, but it is not really needed. However, the "dirty" property is a
useful property of the forms object model.
1) Verifies that both combo boxes have been selected

You can set the limit to list for both combo boxes, and the user will NOT be
able to enter anything else but the given combo lists

I assume that you used the wizard to build the combo boxes. You will need to
bind the form to table c, and then bind the two combo boxes to the two
fields. You could use a wizard to build the form for you. Regardless, you
need to bind the form to table c, and then bind each combo box to the field
in that table. The wizard actually 'asks' you this binding question (it is
the near last question...save value into what field).

Further, if you setup the relationships correctly, then you will NOT be able
to add a record to table c without the two "related" fields entered.

So, to answer your question:

no code at all is needed.

If you don't like the concert of implied saves (or opening a car door
without being nagged to death), then you likely will not like ms-access.
(your best bet is to dump ms-access, and use vb.net for example).

Now, about the only reason you might want to check if the two combo boxes
are filled out is because you DO NOT like the built in error message that
ms-access will give when you try and save.

You thus can use the FORMS before update event, and go:

if isnull(me.combo1) = true then
cancel = True ' this will prevent the update
msgbox "please enter a vlaue in combo 1"
me.combo1.SetFocus ' this is optional, and just sends the
focus (cursor)
' to the comb box..a nice
touch to save the user
' having to do this
exit sub
end if

if isnull(me.combo2) = true then
cancel = True ' this will prevent the update
msgbox "please enter a value in combo 2"
me.combo2.SetFocus ' this is optional, and just sends the
focus (cursor)
' to the comb box..a nice
touch to save the user
' having to do this
exit sub
end if

I would also consider grabbing a book on ms-access (drop by a book store,
they useally have tons of ms-access books). There is a good list here also:

http://home.bendbroadband.com/conradsystems/accessjunkie/resources.html#Books

And, of couse, these newsgroups are very active, and thus there is a lot of
great resources for ms-acces.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top