Hi, I have a Button Update query that I would like to convert to VBA OnClick but not quite sure how to actually make this happen....
This is the actually query:
UPDATE DistTable SET DistTable.Moved = True,
DistTable.MovedBy = [Forms]![HomePage]![Subform_User].[Form]![User],
DistTable.MovAmt = [TotalCollected],
DistTable.MoveDt = Date(),
DistTable.Completed = True
WHERE (((DistTable.Moved)=False)
AND ((DistTable.Completed)=False)
AND ((DistTable.Platform)="TS")
AND ((DistTable.Excluded)=False));
My VBA Code:
Private Sub BtnMMMComplete_Click()
Dim strSQL As String
strSQL = "UPDATE DistributionTable SET Me.Moved = 'True'" & _
"Me.Moveby = '[Forms]![HomePage]![Subform_User].[Form]![User]'" & _
"Me.MoveAmt = '[TotalCollected]'" & _
"Me.MoveDT = Date" & _
"Me.Completed = 'True'" & _
"WHERE Me.Moved = 'False'" & _
"AND Me.Completed = 'False'" & _
"AND Me.Platform = 'TS'" & _
"AND Me.Excluded = 'False'"
DoCmd.RunSQL
End Sub
This is the actually query:
UPDATE DistTable SET DistTable.Moved = True,
DistTable.MovedBy = [Forms]![HomePage]![Subform_User].[Form]![User],
DistTable.MovAmt = [TotalCollected],
DistTable.MoveDt = Date(),
DistTable.Completed = True
WHERE (((DistTable.Moved)=False)
AND ((DistTable.Completed)=False)
AND ((DistTable.Platform)="TS")
AND ((DistTable.Excluded)=False));
My VBA Code:
Private Sub BtnMMMComplete_Click()
Dim strSQL As String
strSQL = "UPDATE DistributionTable SET Me.Moved = 'True'" & _
"Me.Moveby = '[Forms]![HomePage]![Subform_User].[Form]![User]'" & _
"Me.MoveAmt = '[TotalCollected]'" & _
"Me.MoveDT = Date" & _
"Me.Completed = 'True'" & _
"WHERE Me.Moved = 'False'" & _
"AND Me.Completed = 'False'" & _
"AND Me.Platform = 'TS'" & _
"AND Me.Excluded = 'False'"
DoCmd.RunSQL
End Sub