S
shawnrad
I have combo boxes in many places that allow user to add new records.
All worked fine. In preparatioin for beta testing by user, I copied
the db from my machine to his. NONE of the not In List combo boxes
work! Coming back to my machine and the original db, mine no longer
works either. NONE of them. I realized I had also changed the file
location on my computer. Wondering if this somehow affected the
coding, I moved it back to its original location on my machine. Nope,
still doesn't work. HELP!!
This is the error message I get:
"The expression On Not In List you entered as the event property
setting produced the following error: A problem occurred while
Microsoft Access was communicating with the OLE server or ActiveX
Control.
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or
macro.
The db with the coding uses tables linked from a spearate db. Here is
a sample of my coding...
Private Sub Color_NotInList(NewData As String, Response As Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String
Dim NewColor As String
On Error GoTo Err_Color_NotInList
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Please try again."
Else
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("lstAutoColor", dbOpenDynaset)
Msg = "Please enter a new color" & vbCr & "Color."
NewColor = InputBox(Msg)
Rs.FindFirst BuildCriteria("Color", dbText, NewColor)
Do Until Rs.NoMatch
NewColor = InputBox("Color " & NewColor & " already
exists." & _
vbCr & vbCr & Msg, NewColor & " Already Exists")
Rs.FindFirst BuildCriteria("Color", dbText, NewColor)
Loop
Rs.AddNew
Rs![Color] = NewColor
Rs.Update
Response = acDataErrAdded
End If
Exit_Color_NotInList:
Exit Sub
Err_Color_NotInList:
MsgBox Err.Description
Response = acDataErrContinue
End Sub
Thanks for any help anyone can provide! I know nothing about Visual
Basic, so felt pretty cool when I figured it out (actually I copied it
from a website I found but can't find again), and this is driving me
nuts!!
All worked fine. In preparatioin for beta testing by user, I copied
the db from my machine to his. NONE of the not In List combo boxes
work! Coming back to my machine and the original db, mine no longer
works either. NONE of them. I realized I had also changed the file
location on my computer. Wondering if this somehow affected the
coding, I moved it back to its original location on my machine. Nope,
still doesn't work. HELP!!
This is the error message I get:
"The expression On Not In List you entered as the event property
setting produced the following error: A problem occurred while
Microsoft Access was communicating with the OLE server or ActiveX
Control.
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or
macro.
The db with the coding uses tables linked from a spearate db. Here is
a sample of my coding...
Private Sub Color_NotInList(NewData As String, Response As Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String
Dim NewColor As String
On Error GoTo Err_Color_NotInList
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Please try again."
Else
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("lstAutoColor", dbOpenDynaset)
Msg = "Please enter a new color" & vbCr & "Color."
NewColor = InputBox(Msg)
Rs.FindFirst BuildCriteria("Color", dbText, NewColor)
Do Until Rs.NoMatch
NewColor = InputBox("Color " & NewColor & " already
exists." & _
vbCr & vbCr & Msg, NewColor & " Already Exists")
Rs.FindFirst BuildCriteria("Color", dbText, NewColor)
Loop
Rs.AddNew
Rs![Color] = NewColor
Rs.Update
Response = acDataErrAdded
End If
Exit_Color_NotInList:
Exit Sub
Err_Color_NotInList:
MsgBox Err.Description
Response = acDataErrContinue
End Sub
Thanks for any help anyone can provide! I know nothing about Visual
Basic, so felt pretty cool when I figured it out (actually I copied it
from a website I found but can't find again), and this is driving me
nuts!!