Avatar of Gary Croxford
Gary Croxford
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

Access VBA Enable/Disable Form Object

Thank you for looking at my question,

I have a button on a form (cmdTimeForm) that when clicked will open a second form (frmInstrumentTime) for the user to make a further selection about the data to be displayed in a report.

The second form has a range of options organised in option frames and I want only those frames that are pertinent to the selections made on the first form to be enabled.

The code I have so far is below:

Private Sub cmdTimeForm_Click()
    frmInstrument_Time.frame1000.Enabled = True
    frmInstrument_Time.frame2000.Enabled = False
    frmInstrument_Time.frame3000.Enabled = False
    frmInstrument_Time.frame4000.Enabled = False
    frmInstrument_Time.frame6000.Enabled = False
    frmInstrument_Time.frame7000_1.Enabled = False
    frmInstrument_Time.frame7000_2.Enabled = False
    
    DoCmd.SetWarnings False
    DoCmd.OpenForm "frmInstrument_Time", acNormal, , , acFormEdit, acWindowNormal
    docdm.SetWarnings True
End Sub

Open in new window


When I click the button the code falls over with error 424 - Object Required

Please, how do I enable / disable the relevant option groups in the buttons OnClick event before the second form opens?
Microsoft AccessVBA

Avatar of undefined
Last Comment
Dale Fye

8/22/2022 - Mon