J
Jason
I got the following code, it's vb script, I want to use
that code implement it in ms access, and use the data I'm
getting and populating an unbound listbox with that data,
how can I do that? Thanks!
===========================================================
Function GetRecs( pId )
Dim oConn
Dim oCmd
Dim oRs
Dim sOut
Dim sCrLf
sCrLf = Chr(13) & Chr(10)
Set oConn = CreateObject("ADODB.Connection")
oConn.IsolationLevel = 1048576 ' adXactIsolated
oConn.CursorLocation = 3 ' adUseClient
oConn.Mode = 1 ' adModeRead
oConn.Provider = "SQLOLEDB.1"
oConn.Properties("Data Source").Value = "sqlserverName"
oConn.Properties("Initial Catalog").Value = "myData"
oConn.Properties("User ID").Value = "myData_usr"
oConn.Properties("Password").Value = "somepwd"
oConn.Open
Set oCmd = CreateObject("ADODB.Command")
oCmd.ActiveConnection = oConn
oCmd.CommandType = 4
oCmd.CommandText = "mach_DTL"
oCmd.Parameters.Append oCmd.CreateParameter("@pId", 3,
1, , ID)
Set oRs = oCmd.Execute
If Not oRs Is Nothing Then
Do Until oRs.EOF = True
sOut = sOut & "item:" & oRs.Fields
("item").Value & sCrLf
sOut = sOut & "po #:" & oRs.Fields
("po").Value & sCrLf
sOut = sOut & "vendor:" & oRs.Fields
("vendor").Value & sCrLf
sOut = sOut & "date:" & oRs.Fields
("create").Value & sCrLf
sOut = sOut & "cost:" & oRs.Fields
("cost").Value & sCrLf
sOut = sOut & "qty:" & oRs.Fields
("quantity").Value & sCrLf
sOut = sOut
& "********************************************************
" & sCrLf
oRs.MoveNext
Loop
oRs.Close
End If
GetRecs = sOut
oConn.Close
Set oRs = Nothing
Set oCmd = Nothing
Set oConn = Nothing
End Function
that code implement it in ms access, and use the data I'm
getting and populating an unbound listbox with that data,
how can I do that? Thanks!
===========================================================
Function GetRecs( pId )
Dim oConn
Dim oCmd
Dim oRs
Dim sOut
Dim sCrLf
sCrLf = Chr(13) & Chr(10)
Set oConn = CreateObject("ADODB.Connection")
oConn.IsolationLevel = 1048576 ' adXactIsolated
oConn.CursorLocation = 3 ' adUseClient
oConn.Mode = 1 ' adModeRead
oConn.Provider = "SQLOLEDB.1"
oConn.Properties("Data Source").Value = "sqlserverName"
oConn.Properties("Initial Catalog").Value = "myData"
oConn.Properties("User ID").Value = "myData_usr"
oConn.Properties("Password").Value = "somepwd"
oConn.Open
Set oCmd = CreateObject("ADODB.Command")
oCmd.ActiveConnection = oConn
oCmd.CommandType = 4
oCmd.CommandText = "mach_DTL"
oCmd.Parameters.Append oCmd.CreateParameter("@pId", 3,
1, , ID)
Set oRs = oCmd.Execute
If Not oRs Is Nothing Then
Do Until oRs.EOF = True
sOut = sOut & "item:" & oRs.Fields
("item").Value & sCrLf
sOut = sOut & "po #:" & oRs.Fields
("po").Value & sCrLf
sOut = sOut & "vendor:" & oRs.Fields
("vendor").Value & sCrLf
sOut = sOut & "date:" & oRs.Fields
("create").Value & sCrLf
sOut = sOut & "cost:" & oRs.Fields
("cost").Value & sCrLf
sOut = sOut & "qty:" & oRs.Fields
("quantity").Value & sCrLf
sOut = sOut
& "********************************************************
" & sCrLf
oRs.MoveNext
Loop
oRs.Close
End If
GetRecs = sOut
oConn.Close
Set oRs = Nothing
Set oCmd = Nothing
Set oConn = Nothing
End Function