In my application on the form Assets, when the "Asset Type" is a vehicle, a field "VehicleModel" on the sub form becomes visible.
The field "VehicleModelA" is on the Sub form linked to query q01AssetSub. The VBA code is on the Main Form under Current event.
On the form I use the following VBA code and it works well on the form.
I need to learn to do the same on a report.
If Me.cboAsstyp_IDa = 762 Then
Forms("f01AssetsMain").Controls("f01AssetsSub").Fo rm.Controls("Vehmod_IDa").ColumnHidden = False
Else
Forms("f01AssetsMain").Controls("f01AssetsSub").Fo rm.Controls("Vehmod_IDa").ColumnHidden = True
End If
In most cases the reports display similar to the forms.
I use changing visibility of fields on many places in the app.
I have tried various ways, for the field "VehicleModel" is on the Sub Report.
Main report name: r01AssetsMainInfo
Sub Report name: r01AssetsSub
Field Name on Sub Report: txtVehicleModelA
I tried the code below on the main report. No success yet.
If Me.AssetTypeA = "Vehicles" Then
Reports("r01AssetsMainInfo").Controls("r01AssetsSu b").Report.Controls("txtVehicleModelA").ColumnHidd en = False
Else
Reports("r01AssetsMainInfo").Controls("r01AssetsSu b").Report.Controls("txtVehicleModelA").ColumnHidd en = True
End If
I also tried placing VBA on the Sub report.
If Me!txtAsstyp_IDa = 762 Then
Me.txtVehicleModelA.Visible = True
End If