How to enter data into a table using a combobox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've tried to learn for months how to set up the properties in fields in my
forms to enter data directly into a table by typing it into a combo box.
I've tried changing the "limit to list" option to "no" but consistently I
come up with the primary key number on all of the fields in the forms instead
of the actual data. I have tried to adjust the "bound to column" option to
another number with no results. I understand from much investigatin that I
need to write a code in a macro or module, but that is beyond my level of
expertise. Can anyone help me?

Thanks
 
You should check out this link: http://www.mvps.org/access/forms/frm0015.htm
It is pretty much right down the line of what you're looking for I believe.
It does limit you to entering only the one value you type in the comboBox
that would perform the lookup of other records. It may be possible to input
multiple values into a new record if you could somehow break up the NewData
string variable in the NotInLIst event. You can also avoid using the primary
key number by setting the width of that first element to 0" in the
properties, or dragging it all the way to the left in the comboBox creation
wizard. Then you can use the value of the second column instead.
Hope this helps!
~Dana S
 
Thanks, this looks like something that will help me. I'd like very much to
bring up the link you gave me, but it comes up each time as invalid. Could
you check it and see if you typed it in correctly?

Thanks,
Katy
 
That came through fine and looks just what I need. I hate to ask
kindergarden questions in university, but since I'm so new at this, could you
tell me where to insert the name of my database in this module example?
Thanks so much.
Katy
 
Katy,
No worries about asking simple questions... in my eyes that is the purpose
of these forums, to help the pros down to the beginners.. we all have to
start somewhere! :)
So I am pretty sure that there is no need to include the name of the
database as the command: "Set db = CurrentDb" automatically assigns the db
database object to the database where the module resides. Unless your
project deals with multiple databases (in that case it would be out of my
knowledge), you shouldn't have to deal with the database name at all. Please
let me know if this sounds confusing or doesn't clear up your question!
Good luck,
Dana
 
I'll give this a try tomorrow when my mind is fresh and will let you know how
it works. Thanks again for your time and help.

Katy
 
Thanks,
I haven't had much time to work on it today, but first thing this a.m. I
copied the module from the first web page and pasted into the Code Builder in
the "Not in List" event. It didn't work. I haven't had time to see if I
could de-bug it. It may be because I'm using Access 2005 and some of the
expressions are different. I get several messages from the Access gurus that
I can't interpret. I'll try the other webpage tomorrow and see if I have
more luck. If not, and if your patience doesn't wear out, we may talk again.

Thanks again for your help.

Katy
 
For that first code example I sent you, there are two things that need to be
customized for your database, I should've pointed them out to you when I said
you don't need to mess with the database name.
1: Table name; e.g. Set rs = db.OpenRecordset("tblAE", dbOpenDynaset) ;
Replace "tblAE" with the table name that will be added to.
2: Field name; e.g. rs!AEName = NewData ; Replace AEName with the field name
where you will insert your data.
After this the code should work correctly. (Fingers crossed :)
Good luck,
Dana
 
Thanks,
I'll try that tomorrow also.

Katy

Dana809904 said:
For that first code example I sent you, there are two things that need to be
customized for your database, I should've pointed them out to you when I said
you don't need to mess with the database name.
1: Table name; e.g. Set rs = db.OpenRecordset("tblAE", dbOpenDynaset) ;
Replace "tblAE" with the table name that will be added to.
2: Field name; e.g. rs!AEName = NewData ; Replace AEName with the field name
where you will insert your data.
After this the code should work correctly. (Fingers crossed :)
Good luck,
Dana
 
Hi,
I am having some issues with the NotInList function. I've changed the table
name and field name, but continue to get errors. Can you help please?

For the db As ADODB.Database line I get "User-defined type not defined". If
I comment out this line, it gets as far as prompting me to Add the new data
to my table but then I get another error: "Invalid Argurment". It's for Set
rs = db.OpenRecordset("tblIssueDescr", dbOpenDynaset) line.

Any Ideas??
 
I'm having the same problem as A. later in the thread. I've done everything
suggested but NG. I'm running Access2002. Any help appreciated....
 
Back
Top