Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Forms accessing SQL Server data.
If anyone can point me in the right direction I would appreaciate it. I am
trying to populate a data grid on a form to allow the user to select a row and then take that data to a worksheet. Rob |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Forms accessing SQL Server data.
Check this reference
http://msdn.microsoft.com/library/de...idoverview.asp -- - K Dales "Rob Diamant" wrote: If anyone can point me in the right direction I would appreaciate it. I am trying to populate a data grid on a form to allow the user to select a row and then take that data to a worksheet. Rob |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Forms accessing SQL Server data.
Thanks, but that looks like .NET, I am trying to use VBA in Excel. Unless
there is a way for me to use .NET code instead. Rob "K Dales" wrote in message ... Check this reference: http://msdn.microsoft.com/library/de...idoverview.asp -- - K Dales "Rob Diamant" wrote: If anyone can point me in the right direction I would appreaciate it. I am trying to populate a data grid on a form to allow the user to select a row and then take that data to a worksheet. Rob |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Forms accessing SQL Server data.
Rob,
The datagrid is part of VB, not VBA. I think you might be able to reference it and create it using the common controls but have not tested this. Alternatively, use a multi-column listbox to display your data. You can then use the listbox events to copy data to your sheet. e.g. Sub Populate Dim rsData as ADODB.Recordset Dim strSQL as string 'create and execute an sql statement strSQL = "SELECT FieldOne, FieldTwo from table_name" 'get your db data into the recordset- I have assumed you can do this 'lstTarget has same number of columns as there are fields in the rs CopyRSToControl rsData, lstTarget End Sub Public Sub CopyRSToControl(rsInput As ADODB.Recordset, _ ctlTarget As MSForms.Control) '--------------------------------------------------------------------------------------- ' Procedure : CopyRSToControl ' DateTime : 4/15/2004 11:59 ' Author : Robin Hammond ' Purpose :takes a recordset and target listbox or comboand copies ' items in the way they appear 'in the recordset to the list 'assumes that the column count of the listbox is correct to match the rs '--------------------------------------------------------------------------------------- ' Dim vList As Variant Dim lCounter As Long Dim lFieldCounter As Long Dim lFields As Long ctlTarget.Clear 'If rsInput.RecordCount = 0 Then Exit Sub With rsInput .MoveFirst lFields = .Fields.Count ReDim vList(0 To .RecordCount - 1, 0 To lFields - 1) lCounter = 0 Do While Not .EOF For lFieldCounter = 0 To lFields - 1 vList(lCounter, lFieldCounter) = .Fields(lFieldCounter) Next lFieldCounter lCounter = lCounter + 1 .MoveNext Loop End With ctlTarget.List = vList End Sub Robin Hammond www.enhanceddatasystems.com "Rob Diamant" wrote in message ... Thanks, but that looks like .NET, I am trying to use VBA in Excel. Unless there is a way for me to use .NET code instead. Rob "K Dales" wrote in message ... Check this reference: http://msdn.microsoft.com/library/de...idoverview.asp -- - K Dales "Rob Diamant" wrote: If anyone can point me in the right direction I would appreaciate it. I am trying to populate a data grid on a form to allow the user to select a row and then take that data to a worksheet. Rob |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Accessing WorksheetFunction.XX from regular C# Forms application | Excel Worksheet Functions | |||
Multiple people accessing an Excel file from a server at once. | Excel Discussion (Misc queries) | |||
Accessing Server Date | Excel Programming | |||
accessing SQL server from Excel/VBA (instead of ODBC) | Excel Programming | |||
accessing data from an array | Excel Programming |