Problems With VBA

G

Guest

Hello-

I am trying to run the code below and have had problems. Any ideas as to
why the code is not working?

Here are a few details that may be helpful:

- Debugging error is happening on this piece of code: Set rst =
db.OpenRecordset(strSQL)

-I have tested the query (strSQL) several times in the access query editor
and have had no problems getting it to run.

-If I remove the query and just pull the first line directly from the table,
I have not problems.

-The table is a linked table via ODBC. If I create a local table (.mdf) the
code works fine.

Please Help!

Here is the code:


Private Sub ClientName_AfterUpdate()
Me.clientId.Requery
'-----------------------------Caption Name Code-----------------------------

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim m1 As String
Dim m2 As String
Dim m3 As String
Dim m4 As String
Dim m5 As String
Dim m6 As String
Dim m7 As String
Dim m8 As String
Dim m9 As String
Dim m10 As String

strSQL = "SELECT
metric1,metric2,metric3,metric4,metric5,metric6,metric7,metric8,metric9,metric10" & _
" FROM clientSettings" & _
" WHERE (((clientSettings.clientId)=" & _
[Forms]![3-1_modAdVariables]![clientId] & "))"


Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)
'Set rst = db.OpenRecordset("clientSettings")
 
G

Guest

Good question. I should have caught that!

I had a runtime error 3464. The data type was not matching. I changed the
data type and it works fine now.

Thanks. For forcing me to look at the error and think through the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Make table from recordset 2
Run-time error 3061 2
Recordset too large? 10
Excel Export Filtered Form Data To Excel 0
Read query records 3
Renumber field 8
Problem With VBA Code - Help 5
Sql question 17

Top