Hi all, I am trying to basically set the value of an option box through simple VBA, and I just can't get it to work, I receive Run-time error '438': Object doesn't support property or method. Here's the code:
The problem lines are
Forms![Project Leads].Controls(BothOption).Value = True
Forms![Project Leads].FilterOn = False
Forms![Project Leads].Controls(ActiveOption).Value = False
Forms![Project Leads].Controls(DeadOption).Value = False
Basically, depending on the status of a project (Active Lead, Dead Lead, etc) a button needs to open the correct form to view that project. However by default the forms are filtered and have buttons to adjust said filters. When I open the forms, I need to change the filters in order to have the selected project present in the recordset. My issue comes up when trying to simply set the option box back to false
Code:
Public Sub ProjectViewCmd(ID As Long, Stat As String)
Dim i As Integer
Dim MyBox As String
'if it is a project lead
If Stat = "Active Lead" Or Stat = "Dead Lead" Then
DoCmd.OpenForm "Project Leads", acNormal
If Stat = "Dead Lead" Then
Forms![Project Leads].Controls(BothOption).Value = True
Forms![Project Leads].FilterOn = False
Forms![Project Leads].Controls(ActiveOption).Value = False
Forms![Project Leads].Controls(DeadOption).Value = False
End If
DoCmd.SearchForRecord acForm, "Project Leads", acFirst, "[Project ID]=" & ID
'if it belongs in the project list form (i.e. not a lead)
Else
DoCmd.OpenForm "Project List", acNormal
For i = 0 To 4
MyBox = "Check" & CStr(i)
If Forms![Project List].Controls(MyBox).Tag = Stat Then
Forms![Project List].Controls(MyBox).Value = True
End If
Next i
ProjectSort
End If
End Sub
The problem lines are
Forms![Project Leads].Controls(BothOption).Value = True
Forms![Project Leads].FilterOn = False
Forms![Project Leads].Controls(ActiveOption).Value = False
Forms![Project Leads].Controls(DeadOption).Value = False
Basically, depending on the status of a project (Active Lead, Dead Lead, etc) a button needs to open the correct form to view that project. However by default the forms are filtered and have buttons to adjust said filters. When I open the forms, I need to change the filters in order to have the selected project present in the recordset. My issue comes up when trying to simply set the option box back to false