It ain't happenin', folks. Here is my complete sub.. htis should work, right???
What I'm trying to do is save the users typed in text and give them the option of adding it to the list of available options (table "Categories" column "CategoryName"
. I added the err.Description to the msgbox to see why and it says "item not found in this collection". DuH! Apparently the AddNew isn't adding the new text into the record.
I've beat my head against the keyboard to no avail so once again I must consult with the gurus... any ideas, people?
This is for Access 2000.
'preciate any response.
Thanks, Mike
Code:
Private Sub CategoryID_NotInList(NewData As String, Response As Integer)
Dim db As Database, rst As Recordset
Dim strMsg As String, nd As Variant
nd = NewData
strMsg = "'" & nd & "' is not in the Categories List"
strMsg = strMsg & (Chr(13) & Chr(10)) & "Do you want _ to add this name to the list of categories?"
strMsg = strMsg & (Chr(13) & Chr(10)) & "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 rst = db.OpenRecordset("Categories", _ dbOpenDynaset)
On Error Resume Next
rst.AddNew
rst!CategorieName = nd
rst.Update
If Err Then
MsgBox "An error occurred."&(Chr13)&(Chr(10))_
& "(" & Err.Description & ")" & (Chr(13) &_
Chr(10)) & "(Damn! I hate it when that_
happens!)" & (Chr(13) & Chr(10)) & "Please_
try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
End Sub
What I'm trying to do is save the users typed in text and give them the option of adding it to the list of available options (table "Categories" column "CategoryName"
I've beat my head against the keyboard to no avail so once again I must consult with the gurus... any ideas, people?
This is for Access 2000.
'preciate any response.
Thanks, Mike