I have a textbox & a button on a form and would like to search a table. and have the result either on a subform or excel. with the code below nothing is happening.
Private Sub Command114_Click()
Dim strSQL As String
Dim strMyString As String
Dim rs As DAO.Recordset
strMyString = Forms![Main_Menu]!StrArticle
strSQL = "SELECT * FROM tblArticles " & _
"WHERE ArticleNo = '" & strMyString & "';"
Debug.Print strSQL
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
If Not (rs.EOF) Then
'Debug.Print rs![strMyString]
Else
Debug.Print "Nothing found"
End If
Set rs = Nothing
End Sub
Private Sub Command114_Click()
Dim strSQL As String
Dim strMyString As String
Dim rs As DAO.Recordset
strMyString = Forms![Main_Menu]!StrArticle
strSQL = "SELECT * FROM tblArticles " & _
"WHERE ArticleNo = '" & strMyString & "';"
Debug.Print strSQL
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
If Not (rs.EOF) Then
'Debug.Print rs![strMyString]
Else
Debug.Print "Nothing found"
End If
Set rs = Nothing
End Sub