Hello everyone,
I have some areas in my forms which is searched by users. I have written two different codes which are working, when the searched fields become string like below. But they are not worked for integer values.
==> First coding is below worked for string fields.
Private Sub searchbutton_Click()
On Error GoTo Err searchbutton_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Cableform"
stLinkCriteria = "[txtline]=" & "'" & Me![linesearchtxtbox] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_searchbutton_Click:
Exit Sub
Err_searchbutton_Click:
MsgBox Err.Description
Resume Exit_searchbutton_Click
End Sub
==> Second coding is below worked for string fields.
Private Sub searchbutton_Click()
If linesearchtxtbox <> "" Then
cabledataformquery = "SELECT * FROM tblcabledata WHERE line ='" & linesearchtxtbox & "'" & ""
Me.RecordSource = cabledataform
Me.Refresh
Else
MsgBox "Please enter line number first to search"
Me.linesearchtxtbox .SetFocus
End If
End Sub
So the question first is, for the first and second coding. How should I adapt the both code structure, if the searched field is integer instead of string.
The second question, I would like to ask if there is any difference regarding searching speed of both coding? I also welcome to another coding to search offer with same way in the forms.