Hi,
Im trying to do a search on a table called PC on the basis of two field values being inputted to two text boxes: Txtdept and TxtMakeModel. I am using a FlexGrid but the code I have isnt loading the values into the FlexGrid. Can anyone find whats wrong with the code Im using...
Thanks
Private Sub Command1_Click()
Dim adoconnection As ADODB.Connection
Set adoconnection = New ADODB.Connection
adoconnection.Open ("Provider=Microsoft.jet.oledb.4.0;" & "Data Source =H:\AssetTracking.mdb"
MSFlexGrid1.Visible = True
Dim RS As ADODB.Recordset
Set RS = New ADODB.Recordset
RS.Open "select * from PC where PCMakeModel ='" & TxtMakeModel.Text & "' and BusinessDeptID ='" & Txtdept.Text & "'", adoconnection, adOpenDynamic, adLockOptimistic
Dim irow As Integer
With MSFlexGrid1
Rows = 1 'counter used to assign the row number
RS.MoveFirst
While Not RS.EOF
Rows = Rows + 1
RS.MoveNext
Wend
.Rows = Rows
.Cols = 8
irow = 1 'counter used to assign the row number
RS.MoveFirst
While Not RS.EOF
.TextMatrix(irow, 1) = RS!PCID
.TextMatrix(irow, 2) = RS!PCVendor
.TextMatrix(irow, 3) = RS!PCMakeModel
.TextMatrix(irow, 4) = RS!Memory
.TextMatrix(irow, 5) = RS!OperatingSystem
.TextMatrix(irow, 6) = RS!Location
.TextMatrix(irow, 7) = RS!BusinessDeptID
Wend
RS.Close
Set RS = Nothing
End With
End Sub
Im trying to do a search on a table called PC on the basis of two field values being inputted to two text boxes: Txtdept and TxtMakeModel. I am using a FlexGrid but the code I have isnt loading the values into the FlexGrid. Can anyone find whats wrong with the code Im using...
Thanks
Private Sub Command1_Click()
Dim adoconnection As ADODB.Connection
Set adoconnection = New ADODB.Connection
adoconnection.Open ("Provider=Microsoft.jet.oledb.4.0;" & "Data Source =H:\AssetTracking.mdb"
MSFlexGrid1.Visible = True
Dim RS As ADODB.Recordset
Set RS = New ADODB.Recordset
RS.Open "select * from PC where PCMakeModel ='" & TxtMakeModel.Text & "' and BusinessDeptID ='" & Txtdept.Text & "'", adoconnection, adOpenDynamic, adLockOptimistic
Dim irow As Integer
With MSFlexGrid1
Rows = 1 'counter used to assign the row number
RS.MoveFirst
While Not RS.EOF
Rows = Rows + 1
RS.MoveNext
Wend
.Rows = Rows
.Cols = 8
irow = 1 'counter used to assign the row number
RS.MoveFirst
While Not RS.EOF
.TextMatrix(irow, 1) = RS!PCID
.TextMatrix(irow, 2) = RS!PCVendor
.TextMatrix(irow, 3) = RS!PCMakeModel
.TextMatrix(irow, 4) = RS!Memory
.TextMatrix(irow, 5) = RS!OperatingSystem
.TextMatrix(irow, 6) = RS!Location
.TextMatrix(irow, 7) = RS!BusinessDeptID
Wend
RS.Close
Set RS = Nothing
End With
End Sub