J
Jim
I am attempting to move all my access tables to an sql server backend
and continue to use access 97 as the front end...Everything went fairly
smoothly until I started to receive this error message..
Run-Time error '91':
Object variable or With block variable not set
I dont know much about VBA and just want to fix the problem any way I
can..Heres the code and thanks in advance:
Private Sub SendToCTT_Click()
Dim CurrQuery As String 'Checking for absence of
any records
CurrQuery = Me![AlertsCTT].Form.RecordSourÂce
Dim NumEvents As Integer
NumEvents = DCount("*", CurrQuery)
If NumEvents = 0 Then
MsgBox "There are no Alerts to send."
Exit Sub
End If
Dim Criteria As String, MyDB As Database, MySet As Recordset,
MySourceSet As Recordset
Dim AlertNum As Long
AlertNum = Me![AlertsCTT].Form![AlertID]
Criteria = "[AlertID] = " & AlertNum
Set MyDB = DBEngine.Workspaces(0).DatabasÂes(0)
If Me.OpenArgs = "Crisis" Then
Set MySourceSet = MyDB.OpenRecordset("AlertsCrisÂis",
DB_OPEN_DYNASET, dbSeeChanges)
ElseIf Me.OpenArgs = "CTT" Then
Set MySourceSet = MyDB.OpenRecordset("AlertsCTT"Â, DB_OPEN_DYNASET,
dbSeeChanges)
ElseIf Me.OpenArgs = "CaseMgt" Then
Set MySourceSet = MyDB.OpenRecordset("AlertsCaseÂMgt",
DB_OPEN_DYNASET, dbSeeChanges)
ElseIf Me.OpenArgs = "Substance" Then
Set MySourceSet = MyDB.OpenRecordset("AlertsSubsÂtance",
DB_OPEN_DYNASET, dbSeeChanges)
ElseIf Me.OpenArgs = "Clinic" Then
Set MySourceSet = MyDB.OpenRecordset("AlertsClinÂic",
DB_OPEN_DYNASET, dbSeeChanges)
End If
Set MySet = MyDB.OpenRecordset("AlertsCTT"Â, DB_OPEN_DYNASET,
dbSeeChanges)
MySourceSet.FindFirst Criteria ' Find first occurrence.
MySet.AddNew
'MySet!AlertID = MySourceSet!AlertID
MySet!StaffID = MySourceSet!StaffID
MySet!ClientID = MySourceSet!ClientID
MySet!Comment = MySourceSet!Comment
MySet!Date = MySourceSet!Date
MySet!Time = MySourceSet!Time
MySet.Update
MySet.Close
MySourceSet.Close
MsgBox "The selected Alert has been forwarded to CTT."
End Sub
and continue to use access 97 as the front end...Everything went fairly
smoothly until I started to receive this error message..
Run-Time error '91':
Object variable or With block variable not set
I dont know much about VBA and just want to fix the problem any way I
can..Heres the code and thanks in advance:
Private Sub SendToCTT_Click()
Dim CurrQuery As String 'Checking for absence of
any records
CurrQuery = Me![AlertsCTT].Form.RecordSourÂce
Dim NumEvents As Integer
NumEvents = DCount("*", CurrQuery)
If NumEvents = 0 Then
MsgBox "There are no Alerts to send."
Exit Sub
End If
Dim Criteria As String, MyDB As Database, MySet As Recordset,
MySourceSet As Recordset
Dim AlertNum As Long
AlertNum = Me![AlertsCTT].Form![AlertID]
Criteria = "[AlertID] = " & AlertNum
Set MyDB = DBEngine.Workspaces(0).DatabasÂes(0)
If Me.OpenArgs = "Crisis" Then
Set MySourceSet = MyDB.OpenRecordset("AlertsCrisÂis",
DB_OPEN_DYNASET, dbSeeChanges)
ElseIf Me.OpenArgs = "CTT" Then
Set MySourceSet = MyDB.OpenRecordset("AlertsCTT"Â, DB_OPEN_DYNASET,
dbSeeChanges)
ElseIf Me.OpenArgs = "CaseMgt" Then
Set MySourceSet = MyDB.OpenRecordset("AlertsCaseÂMgt",
DB_OPEN_DYNASET, dbSeeChanges)
ElseIf Me.OpenArgs = "Substance" Then
Set MySourceSet = MyDB.OpenRecordset("AlertsSubsÂtance",
DB_OPEN_DYNASET, dbSeeChanges)
ElseIf Me.OpenArgs = "Clinic" Then
Set MySourceSet = MyDB.OpenRecordset("AlertsClinÂic",
DB_OPEN_DYNASET, dbSeeChanges)
End If
Set MySet = MyDB.OpenRecordset("AlertsCTT"Â, DB_OPEN_DYNASET,
dbSeeChanges)
MySourceSet.FindFirst Criteria ' Find first occurrence.
MySet.AddNew
'MySet!AlertID = MySourceSet!AlertID
MySet!StaffID = MySourceSet!StaffID
MySet!ClientID = MySourceSet!ClientID
MySet!Comment = MySourceSet!Comment
MySet!Date = MySourceSet!Date
MySet!Time = MySourceSet!Time
MySet.Update
MySet.Close
MySourceSet.Close
MsgBox "The selected Alert has been forwarded to CTT."
End Sub