Results 1 to 2 of 2

Thread: Help !!!!! Using the (SELECT....IN) query with ADO?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    70

    Cool

    I have a problem with the following query.

    Dim strSQL As String
    Dim Temp As New ADODB.Recordset

    strSQL = "DELETE * FROM tblTemp WHERE Contract IN (SELECT Contract FROM tblWOStatus WHERE (Status = Null))"

    Set Temp = DataEnvironment1.Connection1.Execute(strSQL, , adCmdText)

    Set Temp = Nothing

    This code works if tblWOStatus (in the SELECT part of query) is in the database that Connection1 links to. However it isn't in real life. The table is in another database which I have linked using a second ADO connection (connection2).

    I tried...the following where .rscmdProjStatus is the ADO recordset I trying to use the 'IN' with but doesn't seem to work.

    strSQL = "DELETE * FROM tblTemp WHERE Contract IN '(" & DataEnvironment1.rscmdProjStatus & ")'"

    Set Temp = DataEnvironment1.Connection1.Execute(strSQL, , adCmdText)

    Set Temp = Nothing

    Any body with some ideas please !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  2. #2
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Question Maybe this will help

    Have you tried to use JOIN/UNION in the string? From what I get from you these two tables are in two separate db's. If that is true maybe you have to join/union them before you can use them together.

    I hope this helps.

Posting Permissions

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



Click Here to Expand Forum to Full Width