by edbeeny » Wed May 16, 2007 11:14 am
Try this
Sage Line 500 to extract distinct product and description out of stockm table
Go into Excel F11 and paste this code into the Module
Change the required to fit your network
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Sub get_data()
'Change Server to the server Ip Address
'Change uid to the user Name
'Change pwd to the Password
cn.Open "Driver={SQL Server};" & "Server=127.0.0.1;" & "Database=demo;" & "Uid=User_Name;" & "Pwd=Password;"
sql = "Select distinct product, long_description " _
& "from scheme.stockm"
rs.Open sql, cn
Do Until rs.EOF
Range("A1").CopyFromRecordset rs
Loop
Range("A1").Select
rs.Close
cn.Close
End Sub