I setup a blank, unbound Main Form and created a Sub Form into which I pasted a previously created datasheet view form.
This works fine
On the the Main form I put some command buttons that, when clicked, call procedure that is written in the Main Form's Module.
This is where the problem starts as the click event on the button generates the following error:
"The action or method is invalid because the form or report isn't bound to a table or query"
Here is the function:
Database
Option Explicit
Private Function ApplyTheFilter() As String
Dim strAlpha As String
Dim strField As String
strAlpha = Forms!dsvMainSubContacts.ActiveControl.Tag
strField = Forms!dsvMainSubContacts!txtSearch.Tag
If (strAlpha > "") And (strField > "") Then
Select Case strAlpha
Case "All"
DoCmd.ApplyFilter "Temp", "Company LIKE '*'", ""
Case Else
DoCmd.ApplyFilter "Temp", strField & " LIKE '" & strAlpha & "*'", ""
End Select
ElseIf (strAlpha > "") Then
Select Case strAlpha
Case "All"
DoCmd.ApplyFilter "Temp", "Company LIKE '*'", ""
Case Else
DoCmd.ApplyFilter "Temp", "Company LIKE '" & strAlpha & "*'", ""
End Select
End If
End Function
ps. This is driving me nuts - I have tried to research this for a couple of days now and wouldn't post this query unless as a last resort.
:banghead:
This works fine
On the the Main form I put some command buttons that, when clicked, call procedure that is written in the Main Form's Module.
This is where the problem starts as the click event on the button generates the following error:
"The action or method is invalid because the form or report isn't bound to a table or query"
Here is the function:
Database
Option Explicit
Private Function ApplyTheFilter() As String
Dim strAlpha As String
Dim strField As String
strAlpha = Forms!dsvMainSubContacts.ActiveControl.Tag
strField = Forms!dsvMainSubContacts!txtSearch.Tag
If (strAlpha > "") And (strField > "") Then
Select Case strAlpha
Case "All"
DoCmd.ApplyFilter "Temp", "Company LIKE '*'", ""
Case Else
DoCmd.ApplyFilter "Temp", strField & " LIKE '" & strAlpha & "*'", ""
End Select
ElseIf (strAlpha > "") Then
Select Case strAlpha
Case "All"
DoCmd.ApplyFilter "Temp", "Company LIKE '*'", ""
Case Else
DoCmd.ApplyFilter "Temp", "Company LIKE '" & strAlpha & "*'", ""
End Select
End If
End Function
ps. This is driving me nuts - I have tried to research this for a couple of days now and wouldn't post this query unless as a last resort.
:banghead: