Enter data into tables from a combo Box

W

wilsonk

Can anyone help me write a code (be very basic, because I know nothing about
codes) to enable me to enter data directly from my combo boxes on my forms to
the related table? I've tried to change the "limit to list" property to no,
but when I do that, the data that displays on the forms is the primary key
number. I've tried to change the "bound to column" number to no success.
I've been struggling for this for months and know there must be an easy way.
I'm a self-taught Access user and am doing pretty well with the above
exception.
 
A

Allen Browne

It sounds like the bound column of your combo is zero-width (i.e. you are
displaying something other than the primary key value), so the Not In List
event will not be useful.

How about using the DblClick event of the combo to OpenForm the form where
you can enter items into the lookup table?
Private Sub cbo_DblClick(Cancel As Integer)
DoCmd.OpenForm "MyOtherForm"
End Sub

Then in the AfterUpdate event of that form, requery to combo so it knows
about the new entry you just added:
Private Sub Form_AfterUpdate
Forms![MyOriginalForm]![cbo].Requery
End Sub
 
W

wilsonk

Thanks, I'll try this on another copy of my database. It may be a little
over my head, but I'm good at following directions. Thanks for the help.
Katy

Allen Browne said:
It sounds like the bound column of your combo is zero-width (i.e. you are
displaying something other than the primary key value), so the Not In List
event will not be useful.

How about using the DblClick event of the combo to OpenForm the form where
you can enter items into the lookup table?
Private Sub cbo_DblClick(Cancel As Integer)
DoCmd.OpenForm "MyOtherForm"
End Sub

Then in the AfterUpdate event of that form, requery to combo so it knows
about the new entry you just added:
Private Sub Form_AfterUpdate
Forms![MyOriginalForm]![cbo].Requery
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

wilsonk said:
Can anyone help me write a code (be very basic, because I know nothing
about
codes) to enable me to enter data directly from my combo boxes on my forms
to
the related table? I've tried to change the "limit to list" property to
no,
but when I do that, the data that displays on the forms is the primary key
number. I've tried to change the "bound to column" number to no success.
I've been struggling for this for months and know there must be an easy
way.
I'm a self-taught Access user and am doing pretty well with the above
exception.
 
Top