Results 1 to 2 of 2

Thread: combining 2 tables in object?!?!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Lost in the Mojave Desert
    Posts
    82
    still getting attitude
    basically trying to combine 2 tables into an object and selecting recordsets based on the date and then sorting them out heres what i got so far:

    'sSQL1 = "SELECT * FROM [Customer Info] WHERE [Cust ID Number] in( SELECT [Cust ID Number] FROM Appointments WHERE Appointments.Date BETWEEN #" & sDateFrom & "# And #" & sDateTo & "# )"
    'sSQL1 = "SELECT * FROM Appointments WHERE Date BETWEEN #" & sDateFrom & "# AND #" & sDateTo & "# ORDER BY Appointments.Date,Appointments.Time"
    sSQL1 = "SELECT * FROM Appointments WHERE Date BETWEEN #" & sDateFrom & "# AND #" & sDateTo & "# ORDER BY Appointments.Date,Appointments.Time WHERE [Cust Info] WHERE [Cust Info.Cust ID Number]=[Appointments.Cust ID Number]"


    Set apptRSResult = mdiDBMain.objDataBase.OpenRecordset(sSQL1, dbOpenSnapshot) 'new rs from sdatefrom to sdateto


  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    The first two statements appear, at a glance, to be ok. The last statement has problems (if your code is as exactly as written [only one openrecordset statement], then the last statement is the only one that will be executed):

    sSQL1 = "SELECT * FROM Appointments WHERE Date BETWEEN #" & sDateFrom & "# AND #" & sDateTo & "# ORDER BY Appointments.Date,Appointments.Time WHERE [Cust Info] WHERE [Cust Info.Cust ID Number]=[Appointments.Cust ID Number]"

    might work better if it were written

    sSQL1 = "SELECT a.* FROM Appointments a, [Cust Info] b WHERE Date BETWEEN #" & sDateFrom & "# AND #" & sDateTo & "# and [Cust Info.Cust ID Number]=[Appointments.Cust ID Number]" ORDER BY a.Date,a.Time"

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