H
--Hojo--
I've got an Access ADP connecting to SQL Server 2000. I got tired of
having to build and save a view or a stored procedure every time I
wanted to run a simple Ad Hoc query, so I built a form with a multiline
text box, a button to "Run SQL Query", and a datagrid control to
display the results of my query.
It works great, except I want to be able to select the results, copy
them, and paste them into Excel or an email. Rather than try to build
that functionality into the Microsoft Datagrid 6 control I'm using,
I've tried to replace it with a Microsoft Office Spreadsheet 11.0
control.
One time out of a thousand, I got the Spreadsheet control to accept and
display my query results like this:
Dim rst As ADODB.Recordset
On Error Goto ErrHandler
Set rst = CurrentProject.Connection.Execute(Me.MyTextBox)
If Not rst.EOF Then
Set Me.MyDataGridControl.DataSource = rst
Set Me.SQLResultSpreadsheet.DataSource = rst
'... Resources released later ...
After it worked that one time, I have not been able to duplicate this
very awesome functionality. The one time that it did work, I had first
established a Data Source connection to one of my database tables
through the built-in control "Commands And Options" properties. As you
can see, I also had the existing Datagrid on the form at the same time.
Now I can't go back and get the same result for love or money.
Any help would be appreciated,
--Hojo--
having to build and save a view or a stored procedure every time I
wanted to run a simple Ad Hoc query, so I built a form with a multiline
text box, a button to "Run SQL Query", and a datagrid control to
display the results of my query.
It works great, except I want to be able to select the results, copy
them, and paste them into Excel or an email. Rather than try to build
that functionality into the Microsoft Datagrid 6 control I'm using,
I've tried to replace it with a Microsoft Office Spreadsheet 11.0
control.
One time out of a thousand, I got the Spreadsheet control to accept and
display my query results like this:
Dim rst As ADODB.Recordset
On Error Goto ErrHandler
Set rst = CurrentProject.Connection.Execute(Me.MyTextBox)
If Not rst.EOF Then
Set Me.MyDataGridControl.DataSource = rst
Set Me.SQLResultSpreadsheet.DataSource = rst
'... Resources released later ...
After it worked that one time, I have not been able to duplicate this
very awesome functionality. The one time that it did work, I had first
established a Data Source connection to one of my database tables
through the built-in control "Commands And Options" properties. As you
can see, I also had the existing Datagrid on the form at the same time.
Now I can't go back and get the same result for love or money.
Any help would be appreciated,
--Hojo--