G
Guest
Yesterday I asked the question regarding adding part numbers while in a form.
I tried the fix I got back but it's still not working properly. So I'm
asking again if anyone can help me. I've written the following code:
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
I wrote the code based on an email that directed me to a webside, "Using the
NotInList event of a Combo Box" in Database Solutions for Microsoft Access,
which someone directed me to. I have a part number and a part description. I
need to give the user the ability to add new part numbers and in turn type in
the part description. Today, I received a response back saying the
following: "I think the correct response is acDataErrAdded in combination
with a requery." I'm assuming that means I should change both the Response =
acDataErrContinue and the else Response - acDataErrContinue to
acDataErrAdded, but I'm not sure, so I tried that. but when I changed both
of them, now it is giving me an error message saying it doesn't recognize
that part number because it is not part of the list, and I should pick one
from the list. Obviously I've done something wrong.
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 the description 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, and I could really use some help!
I also don't understand what he meant when he told me to do a requery.
Having said that, I'm really not very knowledgable regarding writing code, so
I'm afraid I'm in over my head!
I'm hoping someone can assist me further as to how to proceed. I would
appreciate any help anyone can give me. I'm really not sure I'm making
myself understood but just let me know and I'll try to clear up any
confusion, if I can. Thank you in advance.
Owl Lover
I tried the fix I got back but it's still not working properly. So I'm
asking again if anyone can help me. I've written the following code:
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
I wrote the code based on an email that directed me to a webside, "Using the
NotInList event of a Combo Box" in Database Solutions for Microsoft Access,
which someone directed me to. I have a part number and a part description. I
need to give the user the ability to add new part numbers and in turn type in
the part description. Today, I received a response back saying the
following: "I think the correct response is acDataErrAdded in combination
with a requery." I'm assuming that means I should change both the Response =
acDataErrContinue and the else Response - acDataErrContinue to
acDataErrAdded, but I'm not sure, so I tried that. but when I changed both
of them, now it is giving me an error message saying it doesn't recognize
that part number because it is not part of the list, and I should pick one
from the list. Obviously I've done something wrong.
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 the description 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, and I could really use some help!
I also don't understand what he meant when he told me to do a requery.
Having said that, I'm really not very knowledgable regarding writing code, so
I'm afraid I'm in over my head!
I'm hoping someone can assist me further as to how to proceed. I would
appreciate any help anyone can give me. I'm really not sure I'm making
myself understood but just let me know and I'll try to clear up any
confusion, if I can. Thank you in advance.
Owl Lover