NotInList when Split

J

Janie

I have never encountered this error before, so any guidance will be
appreciated.

I am working in Access 97.

I have a NotInList Event on a combo box. Works fine UNTIL I split the
Database. Now I get Invalid Operation error. I really do need back end
split from front end, so this is a nasty problem for me. Ideas?

My Code on NotInList Event:
Dim Db As Database, Rs As Recordset
Dim Msg As String, NewID As String

On Error GoTo Err_TTID_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, "NOT ON LIST") = vbNo Then
Response = acDataErrContinue
MsgBox "Please try again.", , "NOT IN LIST"
Else
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("tblTaskTypes", DB_OPEN_TABLE)

Rs.AddNew
Rs![TaskType] = NewData
Rs.Update
Response = acDataErrAdded
End If
 
A

Albert D. Kallal

for the most part, you should just use:

Set Rs = Db.OpenRecordset("tblTaskTypes")

you have:

Set Rs = Db.OpenRecordset("tblTaskTypes", DB_OPEN_TABLE)

DB_OPEN_TABLE does not work for linked tables.......

Just leave that 2nd parameters for openreocordset blank, as ms-access
chooses a good default for you.....
 
M

Marshall Barton

Janie said:
I have never encountered this error before, so any guidance will be
appreciated.

I am working in Access 97.

I have a NotInList Event on a combo box. Works fine UNTIL I split the
Database. Now I get Invalid Operation error. I really do need back end
split from front end, so this is a nasty problem for me. Ideas?

My Code on NotInList Event:
Dim Db As Database, Rs As Recordset
Dim Msg As String, NewID As String

On Error GoTo Err_TTID_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, "NOT ON LIST") = vbNo Then
Response = acDataErrContinue
MsgBox "Please try again.", , "NOT IN LIST"
Else
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("tblTaskTypes", DB_OPEN_TABLE)

Rs.AddNew
Rs![TaskType] = NewData
Rs.Update
Response = acDataErrAdded
End If


I disagree with Albert about not specifying the second
argument. There are methods (Find..., Seek, etc) that only
work with certain types of recordsets so I think you should
be explicit about what type (table, dynaset, snapshot) you
you are expecting instead of letting Access guess.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top