show/hide text boxes when radio button is selected from option box on form

sheesh.katie

Registered User.
Local time
Today, 02:33
Joined
Aug 8, 2012
Messages
10
Hi!
I'm sort of new to Access and can't really say I know what I'm doing. The things I don't know, I get from Google and other people's posts. Problem is I can't seem to find results for what I'm looking for on Access, but can find plenty of results for Javascript!:banghead: I'm creating a database for Recycling where the information can be entered on a form for each recycle station whenever the company has new recycle entries.

The option box has two options: Trash (1) and Recycle (2). Whenever one is selected, it enters a one or a two into a field on my main table, which is great. I want it to do that. The trouble is, though, that on the form whenever an option is selected, I want it to make only those text boxes for that option available.

(In the form, there's the Option Box, then Materials and Material Weight, meant for whenever trash is selected, and Recyclable and Recyclable Weight, meant for whenever recycle is selected.)

I found this code on google that seemed like it was what I wanted, but for some reason the Recyclable box becomes dimmed no matter what the choices are, instead of switching back and forth between what's available. Here's the code:

Private Sub optbox_AfterUpdate()
Select Case Me.optbox.Value
Case 1
cboRecycle.Enabled = False
Case 2
cboRecycle.Enabled = True
End Select
End Sub

cboRecycle is my "Recyclable" box.
I do like how it's dimmed, if only I could get it to switch according to the options! Like I said, I'm new to this, so if somebody could help me out quickly and dumb it down for me, that'd be great! :D
 
You are on the right path. Just change the property from Enabled to Visible. You are good to go. Also on the Form design make the Fields explicitly NOT VISIBLE.
So on selection, the relevent boxes would appear..
Code:
Private Sub optbox_AfterUpdate()
     Select Case Me.optbox.Value
     Case 1
             cboRecycle.Visible = False
         theFieldNameOfMaterial.Visible = True
     Case 2
             cboRecycle.Visible = True
         theFieldNameOfMaterial.Visible = False
      End Select
End Sub
 
How about this:

Code:
Private Sub optbox_AfterUpdate()

     If Me.optbox.Value = 1 Then
        Me.cboRecycle.Enabled = False
        Me.cboRecycle.Locked = False

     Else If Me.optbox.Value = 2 Then
        Me.cboRecycle.Enabled = True
        Me.cboRecycle.Locked = False

     End If

End Sub
 
First one didn't work. Did some editing to the second one and it finally worked! Thanx guys! Life savers!! Appreciate the responses.
 

Users who are viewing this thread

Back
Top Bottom