I am trying to update a field in the Master table by looping through each record and updating it with the corresponding field in my test table. I am to the point where I have pulled the information from the record set to start the loop and I get the following error:
3601 Too few parameters. Expected 1.
Public Function fn_marked() As Integer
Dim db As Database
Dim rst As Recordset
Dim rst_MASTER As Recordset
Dim strSQL As String
Dim strSQL_MASTER As String
On Error GoTo Err_Error
DoCmd.SetWarnings False
strSQL = "UPDATE tbl_ACTIVE INNER JOIN tbl_FILE_SOURCE ON tbl_ACTIVE.Persno =
tbl_FILE_SOURCE.PRNR SET tbl_ACTIVE.marked = True WHERE tbl_FILE_SOURCE.Type='Test'"
DoCmd.RunSQL strSQL, True
Set db = CurrentDb
Set rst_MASTER = db.OpenRecordset("tbl_MASTER")
If rst_MASTER.RecordCount > 0 Then
rst_MASTER.MoveFirst
Do Until rst_MASTER.EOF
If Not rst_MASTER.EOF then
strSQL = "SELECT tbl_ACTIVE.marked FROM tbl_ACTIVE WHERE tbl_ACTIVE.Number= rst_MASTER!Number"
Set rst = db.OpenRecordset(strSQL)
rst_MASTER.Edit
Select Case rst!marked
Case True
rst_Master![Test] = "No"
Case False
rst_Master![Test] = "Yes"
End Select
End If
rst_MASTER.Update
rst_MASTER.MoveNext
Loop
End If
fn_marked = 1
Exit_fn_marked:
DoCmd.SetWarnings True
Exit Function
Err_Error:
MsgBox Err.Number & Err.Description
'failed to finish
fn_marked = -1
Resume Exit_fn_marked
End Function
tbl_Active
column1 Number (Key)
column2 Name (String)
column3 Marked (Boolean)
tbl_MASTER
column1 Number (Key)
column2 Name (String)
column3 Test (String)
END Result of Table Master
column1 1234
column2 John Smith
column3 Yes (value derived from tbl_ACTIVE Boolean field)