Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating Combo Box Field from Yes/No checkbox 1

Status
Not open for further replies.

netrusher

Technical User
Feb 13, 2005
952
US
Below is code I am using on a form. When the PPEEyeProUnsafe
checkbox is true, the code automatically has the Cagegories
ComboBox populate with one of the dropdowns "Personal
Protective Equipment". That works fine. When the
Personal Protective Equipment is selected in that combobox
it cascades to what will appear in the Behaviors ComboxBox.
When something is selected in the Behaviors ComboxBox that
cascades to what will appear in the UnsafeDescription
ComboBox. That works too.

My problem is
When I check another CheckBox i.e. BodyPosition the
Categories Box will populate with the Body Position
value which is also one of the Categories CombBox dropdowns
but then the Behaviors ComboBox still has the values
that go with the Personal Protective Equipment part of
the Categories ComboBox. If I physically select from the
Categories ComboBox, everything works well. When I am just
populating the Categories ComboBox from the Yes/No it does
not update the Behaviors Combo.

I am sorry this is so long and I hope I have explained it
well enough for someone to understand.

Code:
Private Sub PPEEyeProUnsafe_AfterUpdate()
    
If Me.PPEEyeProUnsafe = True Then
Me.Categories.Visible = True
Me.Behaviors.Visible = True
Me.UnsafeDescription.Visible = True
Me.Comments.Visible = True
Me.UnsafeBox.Visible = True
Me.update_rec.Visible = True
Me.Categories.Value = "Personal Protective Equipment"
Else
If Me.PPEEyeProUnsafe = False Then
Me.Categories.Visible = False
Me.Behaviors.Visible = False
Me.UnsafeDescription.Visible = False
Me.Comments.Visible = False
Me.UnsafeBox.Visible = False
Me.update_rec.Visible = False
Me.Categories.Value = ""
  
End If
End If

End Sub
Code:
Private Sub Categories_AfterUpdate()

   On Error Resume Next
   Behaviors.RowSource = "SELECT DISTINCT ObserversCategoriesTbl.Behaviors " & _
            "FROM ObserversCategoriesTbl " & _
            "WHERE ObserversCategoriesTbl.Categories = '" & Categories.Value & "' " & _
            "ORDER BY ObserversCategoriesTbl.Behaviors;"
Me.Behaviors = Blank
Me.UnsafeDescription = Blank

End Sub

Private Sub Behaviors_AfterUpdate()

   On Error Resume Next
   UnsafeDescription.RowSource = "SELECT DISTINCT ObserversCategoriesTbl.UnsafeDescription " & _
            "FROM ObserversCategoriesTbl " & _
            "WHERE ObserversCategoriesTbl.Behaviors = '" & Behaviors.Value & "' " & _
            "ORDER BY ObserversCategoriesTbl.UnsafeDescription;"

End Sub
 

Have you tried this?
Code:
Behaviors.Requery
UnsafeDescription.Requery


Randy
 
How are ya netrusher . . .

[blue]randy700[/blue] should have what you need.

I thought I'd shorten the code on [blue]PPEEyeProUnsafe_AfterUpdate()[/blue]:
Code:
[blue]Private Sub PPEEyeProUnsafe_AfterUpdate()
   Dim Bool As Boolean
   
   Bool = (Me.PPEEyeProUnsafe = True)
   
   Me.Categories.Visible = Bool
   Me.Behaviors.Visible = Bool
   Me.UnsafeDescription.Visible = Bool
   Me.Comments.Visible = Bool
   Me.UnsafeBox.Visible = Bool
   Me.update_rec.Visible = Bool
   Me.Categories = Choose(Bool + 2, "Personal Protective Equipment", "")

End Sub[/blue]
... and a little more raadibility on the SQL's:
Code:
[blue]Private Sub Categories_AfterUpdate()
   Dim SQL As String
   
   SQL = "SELECT DISTINCT Behaviors " & _
         "FROM ObserversCategoriesTbl " & _
         "WHERE [Categories] = '" & Me!Categories & "' " & _
         "ORDER BY [Behaviors];"
   Me!Behaviors.RowSource = SQL
   
   Me.Behaviors = Blank
   Me.UnsafeDescription = Blank

End Sub

Private Sub Behaviors_AfterUpdate()
   Dim SQL As String
   
   SQL = "SELECT DISTINCT UnsafeDescription " & _
         "FROM ObserversCategoriesTbl " & _
         "WHERE ObserversCategoriesTbl.Behaviors = '" & Me!Behaviors & "' " & _
         "ORDER BY ObserversCategoriesTbl.UnsafeDescription;"
   Me!UnsafeDescription.RowSource = SQL

End Sub[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Aceman and Randy 700

Below is the code I have on two different checkboxes
AfterUpdate. When I select the first checkbox the I get
Categories Personal Protective Equipment and in the
Behaviors and UnsafeDescription combo boxes I get the
appropriate lists in the dropdowns.

When I click the second checkbox I get the Categories
Body Position but the Behaviors and UnsafeDescription
comboboxes is not updating to appropriate lists for
the Behaviors and UnsafeDescription.

I was hoping the requery of those boxes would handle this.
Maybe I have them in the wrong position.

If I manually select from the Categories combox the
Behaviors and UnsafeDescription comboxes do populate with
the approriate date. HELP!! What am I doing wrong?

Code:
Private Sub PPEEyeProUnsafe_AfterUpdate()
   
   Dim Bool As Boolean
   
   Bool = (Me.PPEEyeProUnsafe = True)
   
   Me.Categories.Visible = Bool
   Me.Behaviors.Visible = Bool
   Me.UnsafeDescription.Visible = Bool
   Me.Comments.Visible = Bool
   Me.UnsafeBox.Visible = Bool
   Me.update_rec.Visible = Bool
   Me.Categories = Choose(Bool + 2, "Personal Protective Equipment", "")
Categories.Requery
Behaviors.Requery
UnsafeDescription.Requery
Code:
Private Sub PPEBodyProUnsafe_AfterUpdate()

   Bool = (Me.PPEBodyProUnsafe = True)
   
   Me.Categories.Visible = Bool
   Me.Behaviors.Visible = Bool
   Me.UnsafeDescription.Visible = Bool
   Me.Comments.Visible = Bool
   Me.UnsafeBox.Visible = Bool
   Me.update_rec.Visible = Bool
   Me.Categories = Choose(Bool + 2, "Personal Protective Equipment", "")
Categories.Requery
Behaviors.Requery
UnsafeDescription.Requery
 
My second piece of code for the above posting should be

Code:
Private Sub BodyEyesHandsTaskPathUnsafe_AfterUpdate()

   Bool = (Me.BodyEyesHandsTaskPathUnsafe = True)
   
   Me.Categories.Visible = Bool
   Me.Behaviors.Visible = Bool
   Me.UnsafeDescription.Visible = Bool
   Me.Comments.Visible = Bool
   Me.UnsafeBox.Visible = Bool
   Me.update_rec.Visible = Bool
   Me.Categories = Choose(Bool + 2, "Body Position", "")
Categories.Requery
Behaviors.Requery
UnsafeDescription.Requery


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top