I am using this function (AreThereRecords) to check if there are records in a table which I have to start from scratch each time I enter a form to check whether it is empty or not. I use the function a number of times successfully on other tables and it works but on the table I am emptying(PrintBills) it fails. The error is "Compile error: ByRef argument type mismatch". It is looking for a Boolean operator True or False. Can anyone suggest a reason for this and why it doesn't occur in the other instances. Here is some of the code I use (I have highlighted the problem area in Blue":
________________________________________________________________
'Create, declare and instantiate the recordset
Dim R As ADODB.Recordset ' Requests
Dim M As ADODB.Recordset ' Membership
Dim P As ADODB.Recordset ' PrintBills
Dim C As ADODB.Recordset 'Clients
Dim strSQLR As String
Dim strSQLM As String
Dim intAgtID As Integer
Set R = New ADODB.Recordset
Set M = New ADODB.Recordset
Set T = New ADODB.Recordset
Set C = New ADODB.Recordset
Dim SQLText As String
'Set the connection to current project
R.ActiveConnection = CurrentProject.Connection
M.ActiveConnection = CurrentProject.Connection
T.ActiveConnection = CurrentProject.Connection
C.ActiveConnection = CurrentProject.Connection
C.CursorType = adOpenStatic
T.CursorType = adOpenKeyset
T.LockType = adLockOptimistic
'Select unpaid Requests
R.Open "Select * from Requests", Options:=adCmdText
M.Open "Select * from Membership WHERE PaymentID = Null", Options:=adCmdText
T.Open "Select * from tblPrintBills", Options:=adCmdText
C.Open "Select * from Clients", Options:=adCmdText
'Delete all records from the tblPrintBills
Do Until T.EOF
T.Delete
T.MoveNext
Loop
'Call a routine to determine if the recordset contains
'any records
If Not AreThereRecords(R) Then
MsgBox "Recordset Empty...Unable to Proceed"
Else
'Read through Request table
Do Until R.EOF
If IsNull(R("PaymentID")) Then
'Get Clients record
intAgtID = R("AgtID")
C.MoveFirst
C.Find "[AgtID] =" & intAgtID
If Not C.EOF Then
'Check if on tblPrintBills
If Not AreThereRecords(T) Then
'Add record to tbPrintBills
With T
.AddNew
!AgtID = C("AgtID")
!Name = C("Name")
!PrintBill = False
!UnpaidMembership = False
!UnpaidRequests = !UnpaidRequests + 1
.Update
End With
Else
________________________________________________________________
'Create, declare and instantiate the recordset
Dim R As ADODB.Recordset ' Requests
Dim M As ADODB.Recordset ' Membership
Dim P As ADODB.Recordset ' PrintBills
Dim C As ADODB.Recordset 'Clients
Dim strSQLR As String
Dim strSQLM As String
Dim intAgtID As Integer
Set R = New ADODB.Recordset
Set M = New ADODB.Recordset
Set T = New ADODB.Recordset
Set C = New ADODB.Recordset
Dim SQLText As String
'Set the connection to current project
R.ActiveConnection = CurrentProject.Connection
M.ActiveConnection = CurrentProject.Connection
T.ActiveConnection = CurrentProject.Connection
C.ActiveConnection = CurrentProject.Connection
C.CursorType = adOpenStatic
T.CursorType = adOpenKeyset
T.LockType = adLockOptimistic
'Select unpaid Requests
R.Open "Select * from Requests", Options:=adCmdText
M.Open "Select * from Membership WHERE PaymentID = Null", Options:=adCmdText
T.Open "Select * from tblPrintBills", Options:=adCmdText
C.Open "Select * from Clients", Options:=adCmdText
'Delete all records from the tblPrintBills
Do Until T.EOF
T.Delete
T.MoveNext
Loop
'Call a routine to determine if the recordset contains
'any records
If Not AreThereRecords(R) Then
MsgBox "Recordset Empty...Unable to Proceed"
Else
'Read through Request table
Do Until R.EOF
If IsNull(R("PaymentID")) Then
'Get Clients record
intAgtID = R("AgtID")
C.MoveFirst
C.Find "[AgtID] =" & intAgtID
If Not C.EOF Then
'Check if on tblPrintBills
If Not AreThereRecords(T) Then
'Add record to tbPrintBills
With T
.AddNew
!AgtID = C("AgtID")
!Name = C("Name")
!PrintBill = False
!UnpaidMembership = False
!UnpaidRequests = !UnpaidRequests + 1
.Update
End With
Else