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!

Hide a control and set its data path dependent on results from another

Status
Not open for further replies.

Kenny2003

Technical User
Dec 29, 2002
53
GB
Hi,

How can I get access to hide certain fields or controls on a form if a certain field has no data?

Allow me to explain further:

I have a form that displays data = frmPlantMain
and a associated image = Image1
The image is stored outside of the db as a jpeg and the field in the record source table (Image1) contains a link to the image. For example: C:\database\Picture1.jpg

There is also a hidden text box that contains the message "No Image available" = lbl_NoPix
This would be displayed in place of the image if no image has been inserted.

I also have a seperate "insert new image" command button = cmdInsertPic

If the current record has a image then I want to have the controls Image1,lbl_NoPix & cmdInsertPic hidden. This seems fairly easy but it gets more complicated now.

If there is no image I would like these controls visable so that the user can add a new image. I would then need the record to be requiried or refreshed to reflect the fact that a new image has been added.

This is where I fall down - I do not know how to tell access to look at the field in the table (Image1) and if there is no linked or associated image then set the visable propertys of controls a,b & c on the form to true.

I hope I have explained my problem correctly and I thank you for your time in advance.

Regards,

Kenny
 
Your form is bound to your table? If so, remember all the fields of the table are exposed as members of the form's recordset, even if there is no corresponding control placed on the form. Something like this in the form's OnCurrent event could work:
Code:
If IsNull(Me!Image1) Then
    Me!Image1.Visible = True
    Me!lbl_NoPix.Visible = True
    Me!cmdInsertPic.Visible = True
    Else
        Me!Image1.Visible = False
        Me!lbl_NoPix.Visible = False
        Me!cmdInsertPic.Visible = False
End If
Then when an image is added you can do Me.Recalc to turn the Visible property of these controls off.

Ken S.
 
This is similar to what I need to do.

I want an unbound field to appear if the contents of a drop down box equals "Other".

Can this be done. I'm new at Access so it needs to be simple.

Thanks
Sam
 
Sure, use the AfterUpdate event of the combobox. Something like this should work:
Code:
Private Sub [blue]MyCombo[/blue]_AfterUpdate()
Me![blue]MyUnboundTextBox[/blue].Visible = (Me![blue]MyCombo[/blue] = "Other")
End Sub
Replace the control names in blue with your own control names.

HTH,

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top