abenitez77
IS-IT--Management
I get an error msg below. I am trying to run a SQL statement and create a recordset. The first recordset is created with no problems...but the second one is a problem.
This is the line that has the eror msg: "Too few parameters. Expected 1."
Set rs_Null = dbs.OpenRecordset(strSQL)
'Full Code:
Dim lngColumn As Long
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim rs_Null As DAO.Recordset
Dim myField As String
Dim ReqFld As String
Dim strSQL As String
Set dbs = CurrentDb()
' Replace QueryOrTableName with the real name of the table or query
' that is to receive the data from the worksheet
Set rst = dbs.OpenRecordset("tbl_Claims_Upload", dbOpenDynaset)
n = rst.RecordCount
If rst.RecordCount <> 0 Then
' write data to the recordset
'Do While Not rst.EOF
'rst.Fields(lngColumn).value
For i = 0 To n - 1
Set td = dbs.TableDefs(i)
For Each fld In td.Fields
myField = fld.Name
myType = FieldType(fld.Type)
strSQL = "Select * From tbl_Claims_Upload Where " & myField & " Is NULL"
Set rs_Null = dbs.OpenRecordset(strSQL)
n2 = rs_Null.RecordCount
If n2 = 0 Then
'If DCount("*", "tbl_Claims_Upload", myField & " Is Null") = 0 Then 'Or DCount("*", "tbl_Claims_Upload", IsEmpty(myField)) = -1 Then
ReqFld = ReqFld + myField & " has empty Values" & Chr(13)
Else
End If
Next fld
Next i
MsgBox (ReqFld)
'Loop
End If
'rs.Fields("somefield").Type
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
This is the line that has the eror msg: "Too few parameters. Expected 1."
Set rs_Null = dbs.OpenRecordset(strSQL)
'Full Code:
Dim lngColumn As Long
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim rs_Null As DAO.Recordset
Dim myField As String
Dim ReqFld As String
Dim strSQL As String
Set dbs = CurrentDb()
' Replace QueryOrTableName with the real name of the table or query
' that is to receive the data from the worksheet
Set rst = dbs.OpenRecordset("tbl_Claims_Upload", dbOpenDynaset)
n = rst.RecordCount
If rst.RecordCount <> 0 Then
' write data to the recordset
'Do While Not rst.EOF
'rst.Fields(lngColumn).value
For i = 0 To n - 1
Set td = dbs.TableDefs(i)
For Each fld In td.Fields
myField = fld.Name
myType = FieldType(fld.Type)
strSQL = "Select * From tbl_Claims_Upload Where " & myField & " Is NULL"
Set rs_Null = dbs.OpenRecordset(strSQL)
n2 = rs_Null.RecordCount
If n2 = 0 Then
'If DCount("*", "tbl_Claims_Upload", myField & " Is Null") = 0 Then 'Or DCount("*", "tbl_Claims_Upload", IsEmpty(myField)) = -1 Then
ReqFld = ReqFld + myField & " has empty Values" & Chr(13)
Else
End If
Next fld
Next i
MsgBox (ReqFld)
'Loop
End If
'rs.Fields("somefield").Type
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing