I am filtering a form based on the value of a textbox and when I click the next button it queries the main form and I'm trying to query the list box as well, but it is not working. There is no control source on the box, but there is a row source. Any suggestions. I tried to just query the list box but nothing happens.
I also get an error that reads "Field 'DOW' is based on an expression and cannot be edited. Once I click ok, it does the editing and changes the DOW . It looks like it is requiring the main form, but not the list box.
Here is the code for the function that is performed when I hit the next button or the back button.
I also get an error that reads "Field 'DOW' is based on an expression and cannot be edited. Once I click ok, it does the editing and changes the DOW . It looks like it is requiring the main form, but not the list box.
Here is the code for the function that is performed when I hit the next button or the back button.
Code:
Function mfNavigateMealDays(strDirection As String) As Boolean
On Error GoTo Err_PROC
'strDirection is either Next or back
Dim intDOW As Integer, strCriteria As String
intDOW = Me.txtDOW
Select Case strDirection
Case "Next"
If intDOW = 1 Then
Me.cmdBack.Enabled = True
End If
strCriteria = "[DOW] = " & (intDOW + 1)
Me.Filter = strCriteria
Me.FilterOn = True
If intDOW + 1 = 7 Then
Me.cmdNext.Enabled = False
Me.CompleteWeekbtn.Enabled = True
Else
Me.cmdNext.Enabled = True
Me.txtDOW = intDOW + 1
Me.Requery
Me.lstWeeklyMeals.Requery
End If
Case "Back"
If intDOW = 2 Then
Me.cmdBack.Enabled = False
Else
Me.cmdBack.Enabled = True
Me.txtDOW = Me.txtDOW - 1
Me.Requery
Me.lstWeeklyMeals.Requery
End If
strCriteria = "[DOW] = " & (intDOW - 1)
Me.cmdNext.Enabled = True
Me.Filter = strCriteria
Me.FilterOn = True
Case Else
End Select
Exit_PROC:
Exit Function
Err_PROC:
MsgBox Error$
Resume Exit_PROC
End Function