Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Posts
    182

    Unanswered: Whats wrong with this syntax

    I have copied this from a book but it doesn't work.

    Set rstOps = New ADODB.Recordset
    strsql1 = "Select * from SQLACCESS.tblctopl WHERE [est_id] = """ & myestid & """"
    rstOps.Open strsql1, cnn, adOpenStatic, adLockReadOnly, adCmdTable

    I keep getting a runtime error . Incorrect syntax near the keyword 'Select'
    Last edited by livvie; 09-16-04 at 16:30.

  2. #2
    Join Date
    Sep 2003
    Posts
    83
    try the strSQL1 statement as


    strsql1 = "Select * from SQLACCESS.tblctopl " _
    & " WHERE [est_id] = '" & Me![myestid] & "'" & ""

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb

    That is right if your Id is an alphabetic then

    strsql1 = "Select * from SQLACCESS.tblctopl " _
    & " WHERE [est_id] = '" & Me![myestid] & "'"


    Or if your Id is a numeric then
    strsql1 = "Select * from SQLACCESS.tblctopl " _
    & " WHERE [est_id] = " & Me![myestid]

  4. #4
    Join Date
    Apr 2004
    Posts
    182
    Quote Originally Posted by hammbakka
    That is right if your Id is an alphabetic then

    strsql1 = "Select * from SQLACCESS.tblctopl " _
    & " WHERE [est_id] = '" & Me![myestid] & "'"


    Or if your Id is a numeric then
    strsql1 = "Select * from SQLACCESS.tblctopl " _
    & " WHERE [est_id] = " & Me![txtestid]
    The end bit seems to be OK " & Me![txtestid] returns a value but the [est_id] still shows up as [est_id]. I have checked the field and it is est_id.
    I am trying to replace the following code which works but is very slow.

    Set rstOps = New ADODB.Recordset
    strsql1 = "SQLACCESS.tblctopl"
    rstOps.Open strsql1, cnn, adOpenStatic, adLockReadOnly, adCmdTable


    rstOps.Find "est_id=" & myestid

  5. #5
    Join Date
    Apr 2004
    Posts
    182
    Quote Originally Posted by livvie
    The end bit seems to be OK " & Me![txtestid] returns a value but the [est_id] still shows up as [est_id]. I have checked the field and it is est_id.
    I am trying to replace the following code which works but is very slow.

    Set rstOps = New ADODB.Recordset
    strsql1 = "SQLACCESS.tblctopl"
    rstOps.Open strsql1, cnn, adOpenStatic, adLockReadOnly, adCmdTable


    rstOps.Find "est_id=" & myestid

    Got it !. The end bit needed to be adCmdUnspecified not adCmdTable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •