Set value to True in code (Novice)

rfreeman

New member
Local time
Today, 04:01
Joined
Oct 4, 2004
Messages
8
This code runs, but the "validated" value does not change to true.
What am I doing wrong? I know this is a novice question. Help is appreciated.:)


Public Function BatchValidate()
Dim qdfBatchValidate As QueryDef, dbs As Database, cntBatchID, cntValidated, cntValidateTag, rsBatchValidate As Recordset


If isLoaded("BatchResultsEntry") Then

Set dbs = CurrentDb

Set qdfBatchValidate = dbs.QueryDefs("qBatchValidate")
Set cntBatchID = Forms!BatchResultsEntry!BatchID
Set cntValidated = Forms!BatchResultsEntry!Validated
Set cntValidateTag = Forms!BatchResultsEntry!ValidateTag

qdfBatchValidate.Parameters("BatchIDParameter") = cntBatchID

Set rsBatchValidate = qdfBatchValidate.OpenRecordset()


If rsBatchValidate.RecordCount <> 0 Then

rsBatchValidate.MoveFirst
Do Until rsBatchValidate.EOF

rsBatchValidate.Edit
rsBatchValidate("Validated") = True
rsBatchValidate.Update
rsBatchValidate.MoveNext
Loop
End If

cntValidated = True
cntValidateTag.Visible = True

End If

MsgBox "Batch Data Has Been Validated"

End Function
 
CurrentDb.Execute "UPDATE YourTableNameHere SET Validated = True WHERE BatchID = " & Forms("BatchResultsEntry").Form.Controls("BatchID")

Replace YourTableNameHere with the name of the table where the field Validated is.
 

Users who are viewing this thread

Back
Top Bottom