Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Location
    Jacksonville, FL
    Posts
    14

    Question Unanswered: control subform fields independantly?

    I have a subform with 3 checkbox fields in it.. these checkboxes are display only in the subform (they are checked/unchecked via another screen). What I want to happen is, for each record, if one of the fields is checked, then the other two fields must be invisible. I've gotten it to work somewhat. The problem I'm having is that it appears to be taking the value of whatever the last record is and applying the visible=true/false to every record dependant on the values from the last record. . Is there some way to control this at the record level and not have it change the display for every record in the subform?
    The early bird may get the worm. . .
    but it's the second mouse that gets the cheese!

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    You could try something like this....

    Place the following code into the OnCurrent event for your actual SubForm.
    Code:
    If Me.NewRecord = True then
    Me.my1stCheckBoxName.Visible = True
    Me.my2ndCheckBoxName.Visible = True
    Me.my3rdCheckBoxName.Visible = True
    Else
    Call SetChecks
    End If
    Place this Function into the Code module for your actual SubForm:
    Code:
    Private Function SetChecks()
    If Me.my1stCheckBoxName.Value = True Then
    	 Me.my1stCheckBoxName.Visible = True
    	 Me.my2ndCheckBoxName.Visible = False
    	 Me.my3rdCheckBoxName.Visible = False
    ElseIf Me.my2ndCheckBoxName.Value = True Then
    	 Me.my2ndCheckBoxName.Visible = True
    	 Me.my1stCheckBoxName.Visible = False
    	 Me.my3rdCheckBoxName.Visible = False
    ElseIf Me.my3rdCheckBoxName.Value = True Then
    	 Me.my3rdCheckBoxName.Visible = True
    	 Me.my1stCheckBoxName.Visible = False
    	 Me.my2ndCheckBoxName.Visible = True
    Else 
    	 Me.my1stCheckBoxName.Visible = True
    	 Me.my2ndCheckBoxName.Visible = True
    	 Me.my3rdCheckBoxName.Visible = True
    End If
    End Function
    Copy and Paste the following line into the OnClick property for each of the three CheckBoxes located on your actual SubForm:

    =SetChecks()

    Give it a try.....


  3. #3
    Join Date
    Nov 2003
    Posts
    1,487
    Remember...You must do the above in the SubForm itself...not the Parent Form.



  4. #4
    Join Date
    Apr 2004
    Location
    Jacksonville, FL
    Posts
    14
    Hi CyberLynx,
    Thanks for the reply. . Your suggestion would work if I only displayed one record in the subform at a time. However, the subform I have is set up as a multirecord form, in display only. . What I'd like is that when the subform is loaded, for each record, set the visible/invisible value on a field dependant on the checkbox settings.
    I'm thinking it can't do it independant of each record because the field is defined in the "detail" line of the form(in design mode). . setting the field value to visible/invisible would affect every record in the subform for that field. . which explains why it takes the visibility setting of the last record in the subform. .
    I may have to come up with a different way of presenting the data.. . Thanks again for your help.
    The early bird may get the worm. . .
    but it's the second mouse that gets the cheese!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •