Too few arguments?

L4serK!LL

Registered User.
Local time
Today, 14:37
Joined
Jul 22, 2002
Messages
59
Private Sub Knop16_Enter()
Dim rs As Recordset
Dim rs2 As Recordset

Set rs = CurrentDb.OpenRecordset("Allowed_Options")
Set rs2 = CurrentDb.OpenRecordset("Uitvoering")
rs.MoveLast
rs.MoveFirst
While (Not rs.EOF And Not rs.BOF)
MsgBox rs("Standaard")
If (rs("Standaard") = True) Then
' element toevoegen aan Uitvoering
rs2.AddNew
rs2("optiecode") = rs("Optiecode")
rs2("optieomschrijving") = rs("Optieomschrijving")
rs2("optieprijs") = rs("Optieprijs")
rs2("standaard") = rs("Standaard")
rs2.Update
End If
rs.MoveNext
Wend
rs.Close
rs2.Close
Set rs = Nothing
Set rs2 = Nothing

[uitvoering].Requery

End Sub


This piece of code gives a 'Too few arguments: expected 1" error on the 'set rs ....' line :(

What can I do about it?
 
Not sure about your structure or table fields having the same names, but why not just use an Update query?
 
Rich said:
Not sure about your structure or table fields having the same names, but why not just use an Update query?
This little piece of code is supposed to add records to a table based on the selected ones (boolean 'Standaard') in a subform on screen... Don't see how an Update can help me with that... :o
 
Because your opening the underlying table any way and not using the Form.Recordset Clone as the first rs, you can use an Append query with the criteria on the boolean 'Standaard' field
 
And how exactly does an Append Query work? Never used one before :s It's a function that operates on a recordset? or on a form? or...?
 
1. This message usually happens when your query takes a parameter and none was supplied. If the query does need parameters, look up the Parameters collection to see how to supply them.
2. There is no reason for a MoveLast. This just forces Access to read every record in the recordset twice. Once because of the MoveLast and again to process each record.
3. Rich is correct. An append query is much more efficient for this process.

To build the append query start with a select query that selects data from Allowed_Options where Standaard = True. Then change the query type to append and select Uitvoering as the append to table. Save the querydef. Use the .Execute Method to run it.
 
Pat Hartman said:
To build the append query start with a select query that selects data from Allowed_Options where Standaard = True. Then change the query type to append and select Uitvoering as the append to table. Save the querydef. Use the .Execute Method to run it.
Append query seems to do what it needs to do when I run the query itself from the Database Overview Window, but when I try to use CurrentDB.Execute "Add_Defaults", dbFailOnError it gives me 2 expected arguments error...
I'm using 2, [Forms]![FRM_Bestellingen]![Type] and [Forms]![FRM_Bestellingen]![Bestelref] but the form FRM_Bestellingen is loaded so those parameters should be available to the append query (when running the query manually it even works) ... :confused:
 

Users who are viewing this thread

Back
Top Bottom