Hi, this problem is probably very simple to solve but I can't seem to find an answer to it.
I have created a search form that returns all records meeting the criteria back into the search form. What I want to be able to do is to display the records in a datasheet view. This is what I currently have and it works ok but how do I convert?
Private Sub cmdSearch_Click()
Dim LSQL As String
Dim LSearchString As String
Dim LTownString As String
Dim LActive As Integer
Set LSQL = Me.RecordsetClone
If (Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True) And (Len(txtsearchTown) = 0 Or IsNull(txtsearchTown) = True) Then
'MsgBox "You must enter a search string."
Else
LSearchString = txtSearchString
LTownString = txtsearchTown
Select Case Me.Frame99.Value
Case Is = 1
stActive = " AND Active = -1"
Case Is = 2
stActive = " AND Active = 0"
Case Is = 3
stActive = ""
End Select
'Filter results based on search string
LSQL = "select * from tblContacts"
'LSQL = LSQL & " where LastName LIKE '*" & LSearchString & "*' AND Town LIKE '*" & LTownString & "*'" & stActive
If Form_frmMain2.RecordsetClone.RecordCount = 0 Then
MsgBox "No records found"
Else
Form_frmMain2.RecordSource = LSQL
End If
'Clear search string
txtSearchString = ""
txtsearchTown = ""
End If
End Sub
I have created a search form that returns all records meeting the criteria back into the search form. What I want to be able to do is to display the records in a datasheet view. This is what I currently have and it works ok but how do I convert?
Private Sub cmdSearch_Click()
Dim LSQL As String
Dim LSearchString As String
Dim LTownString As String
Dim LActive As Integer
Set LSQL = Me.RecordsetClone
If (Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True) And (Len(txtsearchTown) = 0 Or IsNull(txtsearchTown) = True) Then
'MsgBox "You must enter a search string."
Else
LSearchString = txtSearchString
LTownString = txtsearchTown
Select Case Me.Frame99.Value
Case Is = 1
stActive = " AND Active = -1"
Case Is = 2
stActive = " AND Active = 0"
Case Is = 3
stActive = ""
End Select
'Filter results based on search string
LSQL = "select * from tblContacts"
'LSQL = LSQL & " where LastName LIKE '*" & LSearchString & "*' AND Town LIKE '*" & LTownString & "*'" & stActive
If Form_frmMain2.RecordsetClone.RecordCount = 0 Then
MsgBox "No records found"
Else
Form_frmMain2.RecordSource = LSQL
End If
'Clear search string
txtSearchString = ""
txtsearchTown = ""
End If
End Sub
Last edited: