A
Anthony Viscomi
I have a ComboBox on a form that's values are contained with another table
(Dealer_Name); I would like to be able to have the following code open a
form on the "not in list event" in order to allow the user to enter a value
that isn't contain in the list. The code that I am currently using dies at
the "Set rs = db.OpenRecordset("frm_Dealer_Info", dbOpenDynaset)" line. I
pretty sure that its due to the fact that this line was only meant to open a
table not a form. Is there a way of opening a form?
Thanks in advance!
Anthony
Private Sub Dealer_Name_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim srtMsg As String
srtMsg = "" & NewData & "'is not an avaialable Dealer Name " & vbCrLf &
vbCrLf
strMsg = strMsg & "Do you want to add the new Dealer Name to the list?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to add or No to
re-select."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new Dealer Name?") = vbNo
Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("frm_Dealer_Info", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!Dealer_Name = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
(Dealer_Name); I would like to be able to have the following code open a
form on the "not in list event" in order to allow the user to enter a value
that isn't contain in the list. The code that I am currently using dies at
the "Set rs = db.OpenRecordset("frm_Dealer_Info", dbOpenDynaset)" line. I
pretty sure that its due to the fact that this line was only meant to open a
table not a form. Is there a way of opening a form?
Thanks in advance!
Anthony
Private Sub Dealer_Name_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim srtMsg As String
srtMsg = "" & NewData & "'is not an avaialable Dealer Name " & vbCrLf &
vbCrLf
strMsg = strMsg & "Do you want to add the new Dealer Name to the list?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to add or No to
re-select."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new Dealer Name?") = vbNo
Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("frm_Dealer_Info", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!Dealer_Name = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub