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

Have a field invisible until yes/no field is marked yes 2

Status
Not open for further replies.

tstowe

Technical User
Apr 29, 2003
65
US
My form has a yes/no field called Attached, asking whether or not the member is part of my unit but attached to another. If this is marked YES then I want another field to appear underneath it asking "To Whom" the member is attached.

Your help is greatly appreciated. Thanks ahead of time.

Tony Stowe
 
I have a refinance button on a form. I also have buyer/seller textboxes on a form. If the refinance button is clicked, there is no sale and thus no seller. The seller text box goes invisible so it will not confuse the user.

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

"Be the first to say what is self-evident, and you are immortal." - M. Ebner-Eschenbach
 
Hi tstowe,

Start out with your field set to .Visible = False and in the AfterUpdate event of your checkbox set the other field to .Visible = True (if the checkbox is checked of course).

Enjoy,
Tony
 
Both replies were far quicker than I expected. I appreciate you time and comments. I will try both to see which provides the best results overall for the database. Again, Thanks for your time.
 
One more question (although this will probably sound completely ignorant). Judgehopkins, you stated, "If refinance = -1 then". . .Does -1 mean that the yes/no box IS NOT checked? Thanks for your patience.

Tony
 
Start with the textbox's visible property set to NO. Then on your yes/no control's AfterUpdate event put:

Private Sub y_n_AfterUpdate()
If Me![y/n] = True Then
Me![whom].Visible = True
Else
Me![whom].Visible = False
End If
End Sub
 
Thanks judgehopkins, TonyJollans and fneily:

I went with fneily's code due to its simple incorporation into my dbase.
 
thread181-8770

-1 is Access' way of saying "yes" (i.e., yes, the box is checked)...and that is not a stupid question. I do not know of anyone who was born with VBA imprinted on their brain!

"Be the first to say what is self-evident, and you are immortal." - M. Ebner-Eschenbach
 
Same dbase, I have to issue equipment where the stock numbers (NSN) are required on the report. The sizeable items have different NSN's, i.e.:
Helmet
Small 7526
Medium 7527
Large 7528

I currently have the form set up with the bound field for helmet with a quantity requirement; next to it is a combo box that is linked to a query showing all items with sizes -this combo box lists each item requiring a size, i.e. Helmet, Small or Helmet, Large; next to it is a label that autofills with the correct NSN once a selection is made. Also in this code is a afterupdate for cbohelmet to show the size (large, Medium, etc) once a selection is made. Below is the code.

===================================
Private Sub cbohelmet_AfterUpdate()
Me.txthelmet.Value=dlookup "[lastfour]", "qrysize",
"[equipment]='" & Me.cbohelmet.Value & "'")
Me.cbohelmet.Value=dlookup("[size]", "qrysize", "[equipment]='" & Me.cbohelmet.Value & "'")
End Sub
===================================

What I want to do is have the combo box ONLY pull the information from the query that it needs, i.e. when I select the combo box for Helmet I don't want to see the other items such as chemsuits, sweaters, wet weather items, etc. In my thinking I need to somehow related the Afterupdate code to the label for the item that I am working with, i.e. the code looks at the label for Helmet and realizes that it should only show the sizes for the item. I hope this makes sense. I would love to send the file to anyone not understanding my direction here.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top