L
Ling
I've a problem here:
I am using Microsoft Access and linked it to SQL server.
My code is as below:
note: cmbCustomerDetails is a combo box & type is a value
list
'Declaration
Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rst As ADODB.Recordset
Dim lngMove As Long
Set cnn = New ADODB.Connection
Set cmd = New ADODB.Command
Set rst = New ADODB.Recordset
rst.CursorType = adOpenStatic
'Open the connection
Set cnn = CurrentProject.Connection
'Set up the Command objects's Connection, SQL and
Parameter types
With cmd
.ActiveConnection = cnn
.CommandText = "SELECT tblDo.DoNumber AS [DO No],
tblDo.DoYear AS [Year], tblDo.DoDate FROM tblDo WHERE
tblDo.DoDate Between" & "#" & [Forms]![frmDeliveryOrder
(pop)]![txtstartYr] & "#" & "And" & "#" & [Forms]!
[frmDeliveryOrder (pop)]![txtendYr] & "#"
End With
Set rst = cmd.Execute
Me.cmbCustomerDetails.AddItem "DO No"
Do Until rst.EOF
Me.cmbCustomerDetails.AddItem Item:=(rst![DO No])
rst.MoveNext
Loop
cnn.Close
Set cnn = Nothing
Set cmd = Nothing
Currently, cmbCustomerDetails could not show rst![DO No].
I would like it to show Year, DoDate as well but how do I
do so?
Any ideas?
Thanx
Ling
I am using Microsoft Access and linked it to SQL server.
My code is as below:
note: cmbCustomerDetails is a combo box & type is a value
list
'Declaration
Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rst As ADODB.Recordset
Dim lngMove As Long
Set cnn = New ADODB.Connection
Set cmd = New ADODB.Command
Set rst = New ADODB.Recordset
rst.CursorType = adOpenStatic
'Open the connection
Set cnn = CurrentProject.Connection
'Set up the Command objects's Connection, SQL and
Parameter types
With cmd
.ActiveConnection = cnn
.CommandText = "SELECT tblDo.DoNumber AS [DO No],
tblDo.DoYear AS [Year], tblDo.DoDate FROM tblDo WHERE
tblDo.DoDate Between" & "#" & [Forms]![frmDeliveryOrder
(pop)]![txtstartYr] & "#" & "And" & "#" & [Forms]!
[frmDeliveryOrder (pop)]![txtendYr] & "#"
End With
Set rst = cmd.Execute
Me.cmbCustomerDetails.AddItem "DO No"
Do Until rst.EOF
Me.cmbCustomerDetails.AddItem Item:=(rst![DO No])
rst.MoveNext
Loop
cnn.Close
Set cnn = Nothing
Set cmd = Nothing
Currently, cmbCustomerDetails could not show rst![DO No].
I would like it to show Year, DoDate as well but how do I
do so?
Any ideas?
Thanx
Ling