i am trying to create a form which calls another form filtered according to the values in a text control and date control in the original form.
i am using this code to do so:
Expand|Select|Wrap|Line Numbers
- Private Sub GetTasks_Click()
- Dim strForm As String 'Name of form to open.
- Dim strAccField As String 'Name of the account field.
- Dim strMonField As String 'Name of the month field.
- Dim strHaving As String 'Where condition for OpenForm.
- Const conDateFormat = "\#dd\/mm\/yyyy\#"
- strForm = "frmPlannedTasks"
- strAccField = "account"
- strMonField = "month"
- If Not IsNull(Me.Account) Then
- If Not IsNull(Me.month) Then 'Both fields are filled.
- strHaving = strAccField & " = '" & Me.Account & "' AND " & strMonField & " = " & Format(Me.month, conDateFormat)
- End If
- End If
- DoCmd.OpenForm strForm, acNormal, , strHaving
- End Sub
account = 'Academy Class' AND month = #10/04/2007#
But the sub-form appears empty.
When i run the query the form is based on manually with the same filters i do get results.
(i am quite new to access and VB so let me know if i should be posting any other info.)
any ideas?
thanks, naomi