M
mj
Hi. I have a form with a button that executes the code
below. What it's doing is looping through one table,
tblPlugsTerritory, going to the record in tblPlans where
some of it's field values are equal to
tblPlugsTerritories, and using the value in
tblPlugsTerritories to Update the field called "Plug" in
tblPlans. I think I'm almost there but I continue to get
an error that says "Runtime 3061 Too Few Parameters
Expected 4." Do I have to define tblPlans fields? How
would I do that? Any thoughts would be great! Thanks!
Private Sub UpdatePlugs_Click()
Dim db As Database
Dim rsPlans As Recordset
Dim rsPlugs As Recordset
Set db = CurrentDb
Set rsPlugs = db.OpenRecordset("SELECT * FROM
[tblPlugsTerritory]")
Do While Not rsPlugs.EOF
Set rsPlans = db.OpenRecordset("SELECT * " & _
"FROM [tblPlans] " & _
"WHERE [Territory]=rsPlugs![Territory] AND " &
_
"[MonthID]=rsPlugs![MonthID] AND " & _
"[Year]=rsPlugs![Year] AND " & _
"[ProductGroup]=rsPlugs![ProductGroup]")
rsPlans.Edit
rsPlans(Plug) = rsPlugs(Plug)
rsPlans.Update
rsPlugs.MoveNext
Loop
End Sub
below. What it's doing is looping through one table,
tblPlugsTerritory, going to the record in tblPlans where
some of it's field values are equal to
tblPlugsTerritories, and using the value in
tblPlugsTerritories to Update the field called "Plug" in
tblPlans. I think I'm almost there but I continue to get
an error that says "Runtime 3061 Too Few Parameters
Expected 4." Do I have to define tblPlans fields? How
would I do that? Any thoughts would be great! Thanks!
Private Sub UpdatePlugs_Click()
Dim db As Database
Dim rsPlans As Recordset
Dim rsPlugs As Recordset
Set db = CurrentDb
Set rsPlugs = db.OpenRecordset("SELECT * FROM
[tblPlugsTerritory]")
Do While Not rsPlugs.EOF
Set rsPlans = db.OpenRecordset("SELECT * " & _
"FROM [tblPlans] " & _
"WHERE [Territory]=rsPlugs![Territory] AND " &
_
"[MonthID]=rsPlugs![MonthID] AND " & _
"[Year]=rsPlugs![Year] AND " & _
"[ProductGroup]=rsPlugs![ProductGroup]")
rsPlans.Edit
rsPlans(Plug) = rsPlugs(Plug)
rsPlans.Update
rsPlugs.MoveNext
Loop
End Sub