Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Very simple question on how to do an SQL Select statement in vba

Avatar of jondecker76
jondecker76 asked on
Microsoft AccessSQL
3 Comments1 Solution220 ViewsLast Modified:
I am a fairly experienced PHP / mysql programmer, but I'm having problems doing a very simple query in Microsft Access 2003 using VBA.

All I want to do is check to see if a field exists in a table.
Right now, the code is:

Dim db As DAO.Database
    Dim qd As DAO.QueryDef
    Dim rs As DAO.Recordset
    Dim strSQL As String
    Dim varResult As Variant
    Set db = CurrentDb()
    'Lets validate and check for duplicate data...
    Set rs = db.OpenRecordset("SELECT * FROM Point WHERE Point.Tagname = '" & Me.txtTagName & "';")

but now, no matter what ever I do with rs, i get an error. Now that I have the result set in rs, how do I tell if there were actually any results returned so I can see if this is duplicate data before doing an insert query.

I've tried rs.RecordCount() but it always seems to return a value

I need to evaluate whether or not there were any records matching my select query
Avatar of Rey Obrero (Capricorn1)
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers