Need help with some queries in code

mjdavie

Registered User.
Local time
Today, 16:54
Joined
Sep 17, 2001
Messages
34
Could somebody please help. I have written the following code

Dim db As Database
Dim rst As Recordset

Set db = CurrentDb()
Set rst = db.OpenRecordset("qryFindDuplicate")

If rst.RecordCount >= 1 Then
DoCmd.OpenQuery "qryUpdateMill"
Else

MsgBox "This data has already been input into the Mill Sheet", vbInformation, "Mill Sheet"

End If
rst.Close
Set db = Nothing

The trouble I am getting is that my Query 'qryFindDuplicate' has 2 parameters therefore each time I run this code I get an error message saying "Too few parameters.Expected 2."

Maybe I am going about this the wrong way or maybe it is something simple whatever it is I need some help from you knowledgeable people out there.

Thanks is advance
 
Dim db As Database
Dim rst As Recordset
dim PRm as parameter
dim Qdf as querydef

Set db = CurrentDb()
Set QDF = DBS.QueryDefs("qryFindDuplicate")
For Each PRM In QDF.Parameters
PRM.Value = Eval(PRM.Name)
Next PRM
Set RST = QDF.OpenRecordset(dbOpenDynaset)



If rst.RecordCount >= 1 Then
DoCmd.OpenQuery "qryUpdateMill"
Else

MsgBox "This data has already been input into the Mill Sheet", vbInformation, "Mill Sheet"

End If
rst.Close
Set db = Nothing
set rst=nothing
 
Thankyou very much

Cheers b jackson that worked a treat
Thanks very much
 

Users who are viewing this thread

Back
Top Bottom