Combo box

G

Guest

In Access 2000-2003 I have several combo boxes in my input form. Do I have
to do something special to be able to use these combo boxes to add data, such
as a new part number? Right now I have a drop down menu showing all the
current part numbers, but I want to have the capability of adding new part
numbers without having to go to the actual table. Thank you in advance for
your help.

Owl Lover
 
G

Guest

I tried writing the code for adding to a combo box but I'm still having
problems. Here is the code I wrote:

Dim strAQL As String
Dim i As Integer
Dim Msg As String

' Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub

Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"

i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Part Number...")
If i - vbYes Then
strSQL = "Insert Into tblPart# ([strPartNumber]) " & _
"Values ('" & NewData & "');"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrContinue
Else
Response = acDataErrContinue
End If
End Sub

The problem is that it allows me to type in a new part number, but when I
try to tab out of it, it asks the question again and won't let me out of that
field, and doesn't seem to save the part number in the table. In addition to
adding a part number I have to be able to tab to the next field which is the
part description, and add that as well, then tab out of there and have the
part number and part description save to the table. It's obvious I don't
know what I'm doing, but I could really use some help! I'm not sure if you
will get this today and since today's my day off this is what I'm working on!
So, just to be safe I'll also post it on the general questions area and
hopefully someone will respond. Thank for your help in advance.

Owl Lover
 

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