error code 3251

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi there, i have a problem with my query in my coding. i will just include
the fragment of the code relevant as the entire thing is too long.

Dim qry2 As String - a query
Dim childm As Integer - number
Dim strresult As String - text

qry2 = "SELECT child_id_1, child_id_2, result" & _
"FROM tbl_stay_results" & _
"WHERE (((result) = """ & strresult & """) AND ((child_id_1) = "
& childm & "))" & _
"OR (((result) = """ & strresult & """) AND ((child_id_2) = " &
childm & "));"

Me.Recordset = qry2
Me.Requery

from this i get the error that "operation is not supported for this type of
object"
if anybody can spot my error i will be most grateful.
 
You appear to be missing spaces between the various lines.

qry2 = "SELECT child_id_1, child_id_2, result " & _
"FROM tbl_stay_results " & _
"WHERE (((result) = """ & strresult & """) AND ((child_id_1) = "
& childm & ")) " & _
"OR (((result) = """ & strresult & """) AND ((child_id_2) = " &
childm & "));"

Your qry2 would result in:

SELECT child_id_1, child_id_2, resultFROM tbl_stay_resultsWHERE (((result) =
"something") AND ((child_id_1) = 0))OR (((result) = "something") AND
((child_id_2) = 0));"
 
hi Simeon,

Simeon said:
Dim qry2 As String - a query
Me.Recordset = qry2
Me.Requery

from this i get the error that "operation is not supported for this type of
object"
if anybody can spot my error i will be most grateful.
Me.Recordset is an object not a string.


Dim rs As ADODB.Recordset

Set rs = New ADOBD.Recordset
rs.Open qry2, CurrentProject.Connection, _
adOpenDynamic, adLockOptimistic

Set Me.Recordset = rs

rs.Close
Set rs = Nothing


mfG
--> stefan <--
 
i have checked and they do all have spaces in between now, but I am still
receiving the same error.
 
Sorry, I didn't read all of the code once I saw the errors in the SQL.

Stefan's correct about how you actually open the recordset.
 
thankyou that is what i did wrong, although after correcting this i get
another error that "Run-time error 2580 - the record source 'SELECT
child_id_1, child_id_2, result FROM tbl_stay_results WHERE (((result) =
"Bad") AND ((child_id_1) = 2)) OR (((result)...' specified on this form or
report does not exist."

What could be causing this?
thanks Simeon
 

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

Back
Top