Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This should get you started -- just adjust the code to meet your dbase and
assign to a button -- you will need to make sure the microsoft activex data objects 2.7 reference is selected in the excel vb editor under tools..references as well. Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim strsql As String 'MAIN PROC cn.Provider = "Microsoft.Jet.OLEDB.4.0" cn.Open "\\xxx\xxx\xxx\yyy.mdb", "admin", "" cn.CursorLocation = adUseClient strsql = "SELECT [xxx].[xx], [xx].[RxxxEQ_], [yyy].[yyyy] " _ & "FROM [sdfsdf];" rs.Open strsql, cn Sheets("xxx").Select rs.MoveFirst Do Until rs.EOF = True ActiveCell = rs![xxx] ActiveCell.Offset(0, 1) = rs![xxxx] ActiveCell.Offset(0, 2) = rs![xxxxx] ActiveCell.Offset(0, 3) = rs![xxxxxxx] ActiveCell.Offset(1, 0).Activate rs.MoveNext Loop rs.Close "chris23892 via OfficeKB.com" wrote: Hi all! Here's a new twist: I want to create a command button in Excel that will run a query in my database. Here's why: Our data base is not that locked down, I don't want everyone poking around in this. What I've done is create a query to run the data output that people want. I already have a command button in my form in our data base to run this, export it to a nice neat spreadsheet. What I need is to create a tab in this spreadsheet with a command button that will run this query in my database so people don'r poke around in the actual data base. I'm having issues pointing Excel to the query in VBA. I know this can be done. Any thoughts? -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200808/1 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Wanting to Create A Command Button Command | Excel Programming | |||
why does edit query button not open query | Excel Discussion (Misc queries) | |||
VB's Command Button vs Form's Command Button | Excel Programming | |||
MS Query, command View-Query Properties | Excel Discussion (Misc queries) | |||
Command button macro query | Excel Programming |