Can someone please help me with the problem below?
I used the following Not In List Example, and I get a "type mismatch" error. I am using an Access 2000 database. My table that holds the values is called "Project" and I also created a query from this table, just to do sorting of the values, and it is called "qry_Project". Here is the code I am using, and I'll point out where the code is highlighting the error:
Private Sub ProjectName_NotInList(NewData As String, response As Integer)
Dim db As Database, rs As Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is not an available Value List"
strMsg = strMsg & "@Do you want to add the new Value?"
strMsg = strMsg & "@Click Yes to add or No to re-type it."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?" = vbNo Then
response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("qry_Project", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!Project = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
response = acDataErrContinue
Else
response = acDataErrAdded
End If
End If
End Sub
The line that is highlighting the error, is the following:
Set rs = db.OpenRecordset("qry_Project", dbOpenDynaset)
Can anyone please tell me why I am getting this error? Any help will be greatly appreciated. Thanks so much.
Jerome
I used the following Not In List Example, and I get a "type mismatch" error. I am using an Access 2000 database. My table that holds the values is called "Project" and I also created a query from this table, just to do sorting of the values, and it is called "qry_Project". Here is the code I am using, and I'll point out where the code is highlighting the error:
Private Sub ProjectName_NotInList(NewData As String, response As Integer)
Dim db As Database, rs As Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is not an available Value List"
strMsg = strMsg & "@Do you want to add the new Value?"
strMsg = strMsg & "@Click Yes to add or No to re-type it."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?" = vbNo Then
response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("qry_Project", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!Project = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
response = acDataErrContinue
Else
response = acDataErrAdded
End If
End If
End Sub
The line that is highlighting the error, is the following:
Set rs = db.OpenRecordset("qry_Project", dbOpenDynaset)
Can anyone please tell me why I am getting this error? Any help will be greatly appreciated. Thanks so much.
Jerome