I've been trying to compose a VBA Select Statement in Code in Access 2007 without Success. I have been trying very simple queries and from all of online examples, It's always either complaining of a variable I have set incorrectly or something I do not have decalred. Can someone post an example of a way to write a VBA select Statement to return data from a table and display it in message box?
Dim vFirstName as String
Select tblName.FirstName from tblContactNames WHERE vFirstName
MsgBox ("First name is " + vFirstName)
I"m new to VBA and Access and an old school C++ programmer, so I'm starting out.
Your help is appreciated!!
I've tried this code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim intResult As Integer
Dim strSQL As String
strSQL = "SELECT * FROM tblContactInfo WHERE tblContactInfo.FirstName = Michelle"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
'intResult = rs("RecordCount")