S
Steve
I am trying to fill the array MySearchArray with the results of the split of
my text field, yet it returns an error 13. I have used this code in two other
databases and it has worked fine but now I am getting errors. I have marked
the line below that creates the error.
Thanks
Private Sub cmdSearch_Click()
Dim MySQL, MySearchText As String
Dim MySearchArray() As Variant
Dim I As Integer
MySearchArray = Split(Me.txtSearch, " ") 'ERROR OCCURS HERE!
If Not IsEmpty(MySearchArray) Then
If UBound(MySearchArray) = 0 Then
MySearchText = "*" & MySearchArray(0) & "*"
Else
For I = 0 To UBound(MySearchArray)
MySearchText = MySearchText & "*" & MySearchArray(I) & "*"
Next I
End If
End If
MySQL = "SELECT HotKey from tblC3Notes "
MySQL = MySQL + "WHERE C3NoteTxt "
MySQL = MySQL + "LIKE '" & MySearchText & "' ORDER BY HotKey"
DoCmd.OpenForm "frmFindC3Note", acNormal
Forms![frmFindC3Note]!List1.RowSourceType = "Table/Query"
Forms![frmFindC3Note]!List1.RowSource = MySQL
Forms![frmFindC3Note]!List1.Requery
If Forms![frmFindC3Note]!List1.ListCount = 0 Then
MsgBox "Your search returned no results. Please try again.", _
vbOKOnly + vbInformation, "Sorry..."
DoCmd.Close acForm, "frmFindC3Note", acSaveNo
End If
Me.txtSearch = ""
Me.txtSearch.SetFocus
End Sub
my text field, yet it returns an error 13. I have used this code in two other
databases and it has worked fine but now I am getting errors. I have marked
the line below that creates the error.
Thanks
Private Sub cmdSearch_Click()
Dim MySQL, MySearchText As String
Dim MySearchArray() As Variant
Dim I As Integer
MySearchArray = Split(Me.txtSearch, " ") 'ERROR OCCURS HERE!
If Not IsEmpty(MySearchArray) Then
If UBound(MySearchArray) = 0 Then
MySearchText = "*" & MySearchArray(0) & "*"
Else
For I = 0 To UBound(MySearchArray)
MySearchText = MySearchText & "*" & MySearchArray(I) & "*"
Next I
End If
End If
MySQL = "SELECT HotKey from tblC3Notes "
MySQL = MySQL + "WHERE C3NoteTxt "
MySQL = MySQL + "LIKE '" & MySearchText & "' ORDER BY HotKey"
DoCmd.OpenForm "frmFindC3Note", acNormal
Forms![frmFindC3Note]!List1.RowSourceType = "Table/Query"
Forms![frmFindC3Note]!List1.RowSource = MySQL
Forms![frmFindC3Note]!List1.Requery
If Forms![frmFindC3Note]!List1.ListCount = 0 Then
MsgBox "Your search returned no results. Please try again.", _
vbOKOnly + vbInformation, "Sorry..."
DoCmd.Close acForm, "frmFindC3Note", acSaveNo
End If
Me.txtSearch = ""
Me.txtSearch.SetFocus
End Sub