I am getting an error when i run this piece of code. I have used this code in the past and it works, for some reason i cannot get it to work now.
*****
Dim TestStr As String
Dim qdfTemp As QueryDef
Dim DB As Database
Dim ChkRst As Recordset
'Check to see if the record does exists
TestStr = "select 1 from Event_tbl where InstitutionID = " & I & " and EventDate = #" & D & "#;"
Set DB = CurrentDb
Set qdfTemp = DB.CreateQueryDef("", TestStr)
GetrstTemp qdfTemp
Set ChkRst = qdfTemp.OpenRecordset(dbOpenDynaset, dbSeeChanges)
'Update event table if the record does not exists
If ChkRst.RecordCount > 0 Then
MsgBox "Error Message"
Else
SqlStr = "select * from table"
DoCmd.SetWarnings False
DoCmd.RunSQL SqlStr
DoCmd.SetWarnings True
End If
ChkRst.Close
Set ChkRst = Nothing
*****
Public Function GetrstTemp(qdfTemp As QueryDef)
Dim restemp As Recordset
Dim response As String
With qdfTemp
Set rstTemp = .OpenRecordset(dbOpenDynaset)
With rstTemp
If RecordCount = 0 Then
Exit Function
Else
.MoveLast
.Close
End If
End With
End With
End Function
*****
Thank you for your assistance, Jason Meckley
Database Analyst
WITF
*****
Dim TestStr As String
Dim qdfTemp As QueryDef
Dim DB As Database
Dim ChkRst As Recordset
'Check to see if the record does exists
TestStr = "select 1 from Event_tbl where InstitutionID = " & I & " and EventDate = #" & D & "#;"
Set DB = CurrentDb
Set qdfTemp = DB.CreateQueryDef("", TestStr)
GetrstTemp qdfTemp
Set ChkRst = qdfTemp.OpenRecordset(dbOpenDynaset, dbSeeChanges)
'Update event table if the record does not exists
If ChkRst.RecordCount > 0 Then
MsgBox "Error Message"
Else
SqlStr = "select * from table"
DoCmd.SetWarnings False
DoCmd.RunSQL SqlStr
DoCmd.SetWarnings True
End If
ChkRst.Close
Set ChkRst = Nothing
*****
Public Function GetrstTemp(qdfTemp As QueryDef)
Dim restemp As Recordset
Dim response As String
With qdfTemp
Set rstTemp = .OpenRecordset(dbOpenDynaset)
With rstTemp
If RecordCount = 0 Then
Exit Function
Else
.MoveLast
.Close
End If
End With
End With
End Function
*****
Thank you for your assistance, Jason Meckley
Database Analyst
WITF