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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dim/Undim fields based on selection for input 1

Status
Not open for further replies.

ZiiX

Technical User
Joined
Apr 23, 2004
Messages
10
Location
US
I'm working on a form that requires the user to select either one item or two. If the user selects by means of a check box they are testing two then the fields to fill out will undim and allow them to enter in data. Otherwise, the fields will only show the single option fields.



Also, how do I change the color of a tab control or style/special effect.

Thanks for your time.
-shane
 
It is not real clear what you are working with here. Are you working with a tab control or are you working with a check box and two text boxes.
 
Sorry. Yes, I have a radio button selection option asking the user to either select one widget to test or two. Both require the same fields fo input the acquired data, yet I do not want both sets to show up if they aren't needed.

Thank you so much.
Shane

Entirely sep question was if I could change the format of a tab control, ie background color, special effect etc...

 
I'll answer question 2 first. Tab controls have very limited formating possiblities. You can make the tab text bold, or italics but you can't change the color. You can make the whole tab control transparent but the tabs remain the default color. Also, it is an all or nothing proposition, you can't just change one page to make it different from the others.

On the first question I will give you an example since I don't know the names of your controls. In my example I have an Option Group control called grpChoice with two radio buttons. First button value is 1, second button value is 2.

I then have 4 text box controls called txtInput1A, txtInput1B, txtInput2A, and txtInput2B.

In the On Click event of the Option control I would put the following:

Private Sub grpChoice_Click()
If Me.grpChoice=1 then
Me.txtInput2A.Visible=False
Me.txtInput2B.Visible=False
Else
Me.txtInput2A.Visible=True
Me.txtInput2B.Visible=True
End If
End Sub


Hope this helps.

OnTheFly
 
I appreciate your help earlier. It definately worked for entering in new entries. However, there is something wrong with it retaining the stored value once it is set though. So how do I allow the form to remember that someone has already entered for both options. For example it works as you touch it. But as you scroll back or forward through the collected data it will just hold what you previously typed in. For instance having the default value being = 1 and half the fields already being dim-ed. When someone goes to enter in the new data it shows all the fields and doesnt take them away until they choose 2.

I hope i'm not being too vague but I guess the question would be how you up update it with the correct value so it only shows what the person previously selected as you go to view the entries. Also is there a way to 'half' dim the entry fields?

You were a great help. Hope you had a good weekend.

Shane
 
I think I know what you are asking. You want to remember what choice the user made when the record was first entered so that if they go back to it, the correct sets of text boxes show up again.

If this is the case you can correct that by entering this in the On Current event of the form

Private Sub Form_Current()
If Me.grpChoice=2 Then
Me.txtInput2A.Visible=True
Me.txtInput2B.Visible=True
Else
Me.txtInput2A.Visible=False
Me.txtInput2B.Visible=False
End If
End Sub


Of course you must be storing the value of grpChoice in the record and bind the control grpChoice to that field. For example if your table contains the fields NumWidgetTests as an integer or a byte, Test1, Result1, Test2, Result2. On the form grpChoice would be bound to the field NumWidgetTests, txtInput1A is bound to Test1, txtInput1B is bound to Result1, txtInput2A is bound to Test2 and txtInput2B is bound to Result2.

I hope this was what you were asking. Let me know if it wasn't.

Hope this helps.

OnTheFly
 
Sorry, I forgot the second part of your question. If you mean by 'Half dim' the controls that you want them to show but not be enabled, you can do that by changing the command

Me.txtInput2A.Visible=False to
Me.txtInput2A.Enabled=False

This will only grey out the control rather than hide it.

Hope this helps.

OnTheFly
 
NICE. It is working great. I'm having trouble now trying to keep a field from showing up when both are selected.

For instance option group A is the option to test two widgets instead of just one. Option group B is additional data that may/maynot be required i.e. as-received/audit. (Both of these groups now appear nicely thanks). So someone selects the audit group and also wants to test only one of those widgets. How do i keep widget 2 group from showing up in the audit selection of group B or vice versa...


Thanks so much for your time...
Shane
 
OK, now I am a little confused. Are option groups A and B controling the same 2 sets of text boxes.

Maybe you could give me a list of the controls in question and an example or two of what you want to happen, like

User selects option 1 in Widget Test Option Group and Option 2 in the Audit/Recieved group. This should show txtBox1 and txtBox2 but hide/disable txtBox3 and txtBox4. It should also show txtBoxAudit.

This would help me to give you better information on how to handle the situation.

Hope this helps.

OnTheFly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top