Invalid Argument

X

xRoachx

When I click on a toggle button on a form I get an Invalid Argument error.
I've read through the other posts and tried some of the suggestions, such as
compact & repair and importing to a new db. However, none of these have
worked. The worst thing about this is, is that it worked in another module
and only stopped working when I moved it here. The code is below and is
erroring out on the FindFirst method:

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strVisID As String
Dim strSQL As String

strVisID = Me.VisID

Set db = CurrentDb()
Set rst = db.OpenRecordset("SELECT QAID, VisID FROM QA_PROV_VISITS_T")

rst.FindFirst (strVisID) ****ERROR HERE OR ABOVE***

If rst.NoMatch Then
DoCmd.SetWarnings False

strSQL = "INSERT INTO QA_PROV_VISITS_T ([VisID])" & _
"Values ('" & strVisID & "')" & ";"
DoCmd.RunSQL strSQL

DoCmd.SetWarnings True
Else
If ChildFormIsOpen() Then
CloseChildForm
Else
OpenChildForm
FilterChildForm
End If
End If

db.Close
rst.Close
 
O

Ofer

In this line you didn't specify in which field to search for the value

rst.FindFirst ("FieldName = '" & strVisID & "'")
 
X

xRoachx

Thanks Ofer. That solved it.

Ofer said:
In this line you didn't specify in which field to search for the value

rst.FindFirst ("FieldName = '" & strVisID & "'")

xRoachx said:
When I click on a toggle button on a form I get an Invalid Argument error.
I've read through the other posts and tried some of the suggestions, such as
compact & repair and importing to a new db. However, none of these have
worked. The worst thing about this is, is that it worked in another module
and only stopped working when I moved it here. The code is below and is
erroring out on the FindFirst method:

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strVisID As String
Dim strSQL As String

strVisID = Me.VisID

Set db = CurrentDb()
Set rst = db.OpenRecordset("SELECT QAID, VisID FROM QA_PROV_VISITS_T")

rst.FindFirst (strVisID) ****ERROR HERE OR ABOVE***

If rst.NoMatch Then
DoCmd.SetWarnings False

strSQL = "INSERT INTO QA_PROV_VISITS_T ([VisID])" & _
"Values ('" & strVisID & "')" & ";"
DoCmd.RunSQL strSQL

DoCmd.SetWarnings True
Else
If ChildFormIsOpen() Then
CloseChildForm
Else
OpenChildForm
FilterChildForm
End If
End If

db.Close
rst.Close
 
Top