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

setting labels visible/invisible after update event in combo box?

Status
Not open for further replies.

rienk

Technical User
Apr 2, 2003
9
US
Hi,

I've got a combo box that is supposed to update the layout of my form, depending on what a user selects. So a number of textboxes will be disabled or something like that. These are some of the possible sollutions I'm thinking of:

1) disable/enable certain textfields and somehow changing their background so it's clear which textfield the user should fill out.

2) create several subforms and depending on the selection of the combo box show one of those subforms in the main form.

3) setting certain text-labels visible / invisible or changing the content of a text-label.

Are any of these possible and if so, how?

thank you!
 
I have a combo box called "cboUser" and a button named "downdaybut" (you would substitute your LABEL name and TEXT box name). Now, my combobox is based on a table where the primary key is a number and then has a field for the users name. The name appears in the combobox (I used the combo box wizard) but you must use the primary key in your code. I have the following on the AfterUpdate event from the combobox's property sheet:

If (Me.cboUser = 7) Or (Me.cboUser = 6) Then
Me.downdaybut.Enabled = True
Me.downdaybut.Visible = True
Else
Me.downdaybut.Enabled = False
Me.downdaybut.Visible = False
End If

So, in my case, if they click on Administration or Warehouse from the combobox, the Down Day button appears. For everyone else its invisible.

Neil
 
Rienk, I hope you might get some ideas from this. I have a form that has a refinance checkbox. If that checkbox is checked, then the seller fields disappear. If that checkbox is not checked, then the seller fields remain on the form.

Code:
Private Sub Refinance_AfterUpdate()
'If refinance button is checked
'seller fields disappear
    If Refinance = -1 Then
        Me![SellerLastName].Visible = False
        Me![SellerFirstName].Visible = False
    Else
'If refinance button is not checked
'seller fields appear
        Me![SellerLastName].Visible = True
        Me![SellerFirstName].Visible = True
    End If
End Sub
 
Another hint: I use the following code to refresh the form when the user moves to a new form; otherwise, the focus gets all screwed up.

I.e., OrderNumber is the next control after the refinance checkbox. If I do not use the code below, if the user clicks refinance on one form and the seller info disappears, then the next record the user works on will also have invisible seller fields. If I use the code below, that kind of nonsense stops.

[smarty]

Code:
Private Sub Form_Current()
    Me!OrderNumber.SetFocus
    Call Refinance_AfterUpdate
'refreshes form so refinance check will work
End Sub
 
Thanks, you two, the methods work perfectly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top