Hiding option buttons based on other option buttons

bugtobug31

New member
Local time
Today, 09:17
Joined
Jun 9, 2011
Messages
4
Hello,

I'm making a report in Access 2003. I have one sent of option buttons named workingorder and another set named compcondition. When option 1 and 3 are selected in workingorder, I would like compcondition to be hidden. When option 2 is selected, I need to see compcondition.

I have limited experience with code so hopfully it's just an easy fix that I'm missing. My code in the On Open event for the report is:

Code:
Private Sub Report_Open(Cancel As Integer)
If Me.fmeLMASWorkingOrder = 2 Then Me.fmeLMASCompCondition.Visible = True Else Me.fmeLMASCompCondition = False
End Sub

It tells me I have an expression that has no value and highlights "If Me.fmeLMASWorkingOrder = 2 Then"

I've tried a couple different ways can can't get this to work. Please help!
 
You will need this code in the OnOpen event of your form as you have it, but you would also need this code in the AfterUpdate event of the workingorder option group control:

Code:
If Me.workingorder = 2 then
     Me.compcondition.Visible = True
Else
     Me.compcondition.Visible = False
End If
 
I'm working in a report, not a form. The option groups have no events.

I realized the if statement should depend on the table, not the report. Here's the code I'm using now:

Code:
Private Sub Report_Open(Cancel As Integer)
    If Tables!tblRASerialNumberEval!LMAS - WorkingOrder = 2 Then 
Me.fmeLMASCompCondition.Visible = True 
Else Me.fmeLMASCompCondition = False
End Sub

The error says object required. Am I referencing the table or the field wrong? Whenever I save, it puts spaces around the dash in the field. I tried putting it in brackets but it didn't work.

I would really appreciate any help! Thank you
 
You will need to refer to the field from an open recordset. If your report is based on the same table where the value is stored, you can simple place a bound, not visible control in your report and refer to the value of that control, if not, you could do a lookup on the table to read the value and then evaluate the returned value from the lookup.
 
You don't make something visible or not visible on a report by using the Open Event. You need to use the ON FORMAT event of THE SECTION the control that you want to make visible/not visible is in.
 
Thanks to you both! I got my first control to work, I'm sure the rest will be no problem now.
 

Users who are viewing this thread

Back
Top Bottom