Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / April 2004

Tip: Looking for answers? Try searching our database.

SQL query in Excel 2000 using VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brandon A. Dreiling - 02 Apr 2004 12:30 GMT
Greetings,

I am looking for help on how to reference a specific worksheet cell to be
used in a SQL (Sybase 11) query.

I have working VBA code that will pull data as long as I hard code the date
or date range; however, I would like a single cell, or even a msgbox to be
used for the date.

If anyone has any ideas, I would appreciate it.

Thanks,
Brandon
Bob Phillips - 02 Apr 2004 12:34 GMT
SQL query in Excel 2000 using VBABrandon,

Essentially, it seems that Application.Inputbox with a type of 8 would be what you want, but post the code.

Signature

HTH

Bob Phillips
   ... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

 Greetings,

 I am looking for help on how to reference a specific worksheet cell to be used in a SQL (Sybase 11) query.

 I have working VBA code that will pull data as long as I hard code the date or date range; however, I would like a single cell, or even a msgbox to be used for the date.

 If anyone has any ideas, I would appreciate it.

 Thanks,
 Brandon
Brandon A. Dreiling - 03 Apr 2004 12:59 GMT
Thanks for offering to help. Below is the query. I need to be able to have
the date 2004-03-18 pulled from a cell in a workbook and have the other date
2004-03-19 generated by adding 1 to the date from the cell.

Thanks again,
Brandon

SELECT tbl_ticket.vendor_code, tbl_ticket.reported_on,
tbl_ticket.work_queue_code, tbl_ticket.ticket_status_code,
tbl_ticket.ticket_num  FROM BB_TT.dbo.tbl_ticket tbl_ticket  WHERE
(tbl_ticket.reported_on>{ts '2004-03-18 00:00:00'} And
tbl_ticket.reported_on<{ts '2004-03-19 00:00:00'}) AND
(tbl_ticket.ticket_status_code<>2)  ORDER BY tbl_ticket.vendor_code

On 4/2/04 6:34 AM, in article Ojz7DaKGEHA.1368@TK2MSFTNGP11.phx.gbl, "Bob
Phillips" <bob.phillips@notheretiscali.co.uk> wrote:

> Brandon,
>  
> Essentially, it seems that Application.Inputbox with a type of 8 would be what
> you want, but post the code.
Bob Phillips - 03 Apr 2004 13:12 GMT
Re: SQL query in Excel 2000 using VBAHi Brandon,

Assuming that the date is in cell A1 on Sheet 1, try this

   dtTest = Format(Worksheets("Sheet1").Range("A1").Value, "yyyy-mm-dd")
   dtTest2 = Format(Worksheets("Sheet1").Range("A1").Value + 1, "yyyy-mm-dd")
   sSQL = "SELECT tbl_ticket.vendor_code, " & _
          "       tbl_ticket.reported_on, " & _
          "       tbl_ticket.work_queue_code, " & _
          "       tbl_ticket.ticket_status_code, " & _
          "       tbl_ticket.ticket_num  " & _
          "FROM   BB_TT.dbo.tbl_ticket tbl_ticket" & _
          "WHERE (tbl_ticket.reported_on>{ts '" & dtTest & "'} And " & _
          "       tbl_ticket.reported_on<{ts '" & dtTest2 & "'}) AND " & _
          "       (tbl_ticket.ticket_status_code<>2)" & _
          "ORDER BY tbl_ticket.vendor_code"

and use sSQL in your query

Signature

HTH

Bob Phillips
   ... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

 Thanks for offering to help. Below is the query. I need to be able to have the date 2004-03-18 pulled from a cell in a workbook and have the other date 2004-03-19 generated by adding 1 to the date from the cell.

 Thanks again,
 Brandon

 SELECT tbl_ticket.vendor_code, tbl_ticket.reported_on, tbl_ticket.work_queue_code, tbl_ticket.ticket_status_code, tbl_ticket.ticket_num  FROM BB_TT.dbo.tbl_ticket tbl_ticket  WHERE (tbl_ticket.reported_on>{ts '2004-03-18 00:00:00'} And tbl_ticket.reported_on<{ts '2004-03-19 00:00:00'}) AND (tbl_ticket.ticket_status_code<>2)  ORDER BY tbl_ticket.vendor_code

 On 4/2/04 6:34 AM, in article Ojz7DaKGEHA.1368@TK2MSFTNGP11.phx.gbl, "Bob Phillips" <bob.phillips@notheretiscali.co.uk> wrote:

   Brandon,

   Essentially, it seems that Application.Inputbox with a type of 8 would be what you want, but post the code.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.