+ Reply to Thread
Results 1 to 2 of 2

problems setting sql query

Hybrid View

  1. #1
    Registered User
    Join Date
    07-09-2012
    Location
    UK
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    35

    problems setting sql query

    i have the following code and am stuck how to set mySQL as an existing SQL query named Qry_Report1

    could anyoneone help me with what i am missing please

    Sub SQLTransfer()
    Dim dayFrom As String
    Dim dayTo As String
    Dim MySQL As String
    
    dayFrom = Me.TextFrom
    dayTo = Me.TextTo
    
    MySQL = "SELECT Main.FaultNumber, Main.DateFault, Main.TimeFault, Main.NGTEngineer, Main.NGTEngineerTelephone, Main.Site, Main.BriefDescription, Main.PassedTo, Main.Additional" & _
    "From Main" & _
    "WHERE (((Main.TimeFault)>=#" & dayFrom & "# And (Main.TimeFault)<=#" & dayTo & "#));"
    
    
    
    
    Dim cnn1 As ADODB.Connection
    Set cnn1 = CurrentProject.Connection
    Dim myRecordSet As New ADODB.Recordset
    myRecordSet.ActiveConnection = cnn1
    myRecordSet.Open MySQL
    
    End Sub
    Thanks

    Ste

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: problems setting sql query

    ain't it just
    MySQL = "Qry_Report1"
    instead of writing out the sql string?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1