Im attemting to create a search between 2 dates on a navigation form, the particular form is a continuous form using a query.
The VBA code sample I aquired from a Utube Tutorial
The VBA code in the form when not attached to the navigation form works fine , when running the code under the nav form I get the error:'
Run-Time error 2491
The action or method is invalid because the form or reprt isnt bound to a table or query.
Here is the VBA Code in question
Option Compare Database
Option Explicit
Private Sub cmdSearchPC_Click()
' Search Button
Call Search
End Sub
Sub Search()
Dim StrCriteria, task As String
Me.Refresh
If IsNull(Me.txtDateFromPC) Or IsNull(Me.txtDateToPC) Then
MsgBox "Please enter the date range", vbInformation, "Date Range Required"
Me.txtDateFromPC.SetFocus
Else
StrCriteria = "([DateCreated] >= #" & Me.txtDateFromPC & "# And [Datecreated] <= #" & Me.txtDateToPC & "#)"
task = "Select * ProgressClaimList2Q where (" & StrCriteria & ") order by [DateCreated]"
DoCmd.ApplyFilter task
End If
End Sub
The VBA code sample I aquired from a Utube Tutorial
The VBA code in the form when not attached to the navigation form works fine , when running the code under the nav form I get the error:'
Run-Time error 2491
The action or method is invalid because the form or reprt isnt bound to a table or query.
Here is the VBA Code in question
Option Compare Database
Option Explicit
Private Sub cmdSearchPC_Click()
' Search Button
Call Search
End Sub
Sub Search()
Dim StrCriteria, task As String
Me.Refresh
If IsNull(Me.txtDateFromPC) Or IsNull(Me.txtDateToPC) Then
MsgBox "Please enter the date range", vbInformation, "Date Range Required"
Me.txtDateFromPC.SetFocus
Else
StrCriteria = "([DateCreated] >= #" & Me.txtDateFromPC & "# And [Datecreated] <= #" & Me.txtDateToPC & "#)"
task = "Select * ProgressClaimList2Q where (" & StrCriteria & ") order by [DateCreated]"
DoCmd.ApplyFilter task
End If
End Sub