Referencing a subform datasheet object from a form

Dugantrain

I Love Pants
Local time
Today, 13:41
Joined
Mar 28, 2002
Messages
221
What I have is a main form with a subform datasheet. When the user clicks an Option button on the main form, I need for every record in a certain field on the datasheet to go to "0". So far, my code is:

Private Sub Option33_Click()
If [Forms]![frmsparesite].[Form]![Option33] = True Then
[Forms]![frmsparesite]![SubformSpareSiteParts].[Form]![Need] = 0
End If
End Sub

This puts a zero in the top field only; I need it to place a zero in every field. How may I accomplish this?
 
DuganTrain,

Experimenting with code like the following to update the table behind the subform will hopefully move you closer to a solution.
Code:
If [Forms]![frmsparesite].[Form]![Option33] = True Then
  
      Dim strSQL As String
      strSQL = "UPDATE TblBehindSubForm SET TblBehindSubform.need = 0 " & _
        "WHERE TblBehindSubForm.LinkField=[forms]![FrmMainForm].[LinkField];"

       DoCmd.SetWarnings False
            DoCmd.RunSQL strSQL
       DoCmd.SetWarnings True
        
        Me.Recalc
End If

Regards,
Tim
 

Users who are viewing this thread

Back
Top Bottom