Dear Access experts, here am I again with my new problem.
I want to populate the RowSource for my combo box on a form filtering it by a value in the table field.
I’m running the following Sub on the GotFocus event of the combo box (CBO) in the FORM. When I debug it, I get a compile error that says that the variable TABLE is not defined (the first instance of it in the SELECT statement).
I’ve tried to define the table first (Dim TABLE As TableDef), but then I was getting another compile error, this time on Field1: Method or data member not found.
I have the Option Explicit header in my code. I cannot figure out what the problem is (((
Private Sub CBO_GotFocus()
Dim SQL As String
SQL = "SELECT TABLE.Field1, TABLE.Field2 FROM TABLE " & _
"WHERE TABLE.Field3 Like '" & [Forms]![FORM]![Field] & "'"
If TABLE.Field4 = "some text1" Then
Me.CBO.RowSource = "some text2"
Else
Me.CBO.RowSource = SQL
End If
Me.CBO.Requery
End Sub
I want to populate the RowSource for my combo box on a form filtering it by a value in the table field.
I’m running the following Sub on the GotFocus event of the combo box (CBO) in the FORM. When I debug it, I get a compile error that says that the variable TABLE is not defined (the first instance of it in the SELECT statement).
I’ve tried to define the table first (Dim TABLE As TableDef), but then I was getting another compile error, this time on Field1: Method or data member not found.
I have the Option Explicit header in my code. I cannot figure out what the problem is (((
Private Sub CBO_GotFocus()
Dim SQL As String
SQL = "SELECT TABLE.Field1, TABLE.Field2 FROM TABLE " & _
"WHERE TABLE.Field3 Like '" & [Forms]![FORM]![Field] & "'"
If TABLE.Field4 = "some text1" Then
Me.CBO.RowSource = "some text2"
Else
Me.CBO.RowSource = SQL
End If
Me.CBO.Requery
End Sub