Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing WorksheetFunction.XX from regular C# Forms application Jes Ramsing Excel Worksheet Functions 1 June 16th 05 12:21 PM
Multiple people accessing an Excel file from a server at once. UABCSA Excel Discussion (Misc queries) 1 May 2nd 05 05:41 PM
Accessing Server Date Sree Excel Programming 0 August 16th 04 01:45 PM
accessing SQL server from Excel/VBA (instead of ODBC) Danut Excel Programming 5 December 11th 03 05:15 PM
accessing data from an array Tom Ogilvy Excel Programming 5 September 9th 03 04:21 AM


All times are GMT +1. The time now is 10:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"