Hi,
I have Datacombo(cbofields(0)) and Datagrid (grdDataGrid) on the form. What i'm trying to do is when i select item on the datacombo, only the relevant record will be displayed on the datagrid. By default, the datagrid will display all the records.
This code is taken from the sample database on the internet.
This is what i've done,
When i open the form, by default the datagrid will display all the records, but the problem is, when i select on the datacombo, the datagrid didn't display the relevant record.
The problem is, it displays all the records.
Any idea? thanx in advance..
I have Datacombo(cbofields(0)) and Datagrid (grdDataGrid) on the form. What i'm trying to do is when i select item on the datacombo, only the relevant record will be displayed on the datagrid. By default, the datagrid will display all the records.
This code is taken from the sample database on the internet.
This is what i've done,
Code:
Private Sub cbofields_Click(Index As Integer, Area As
Integer)
If Area = 2 Then
selmodel = cbofields(0).BoundText
Form_Load
End If
End Sub
Private Sub Form_Load()
Dim db As Connection
Me.Top = 0
Me.Left = 0
Me.Height = 5130
Me.Width = 6090
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=MSDataShape;......."
Set adoPrimaryRS = New Recordset
Set rsgtotal = New Recordset
If selmodel = "" Then
adoPrimaryRS.Open "SELECT cust_no, type, pt,
receivedt FROM [orderdetails] LEFT JOIN [orders]
ON [orderdetails].sn = [orders].sn", db,
adOpenStatic, adLockOptimistic
Else
adoPrimaryRS.Open "SELECT [customer].cust_no,
[orderdetails].type, [orderdetails].pt,
[orders].receivedt FROM ([orders] LEFT JOIN
[customer]ON [orders].cust_no =
[customer].cust_no) INNER JOIN [orderdetails] ON
[orders].sn= [orderdetails].sn WHERE type = "
& "'" & Trim(selmodel) & "'" & ", db"
End If
AdoType.ConnectionString = "PROVIDER=MSDataShape;......."
AdoType.RecordSource = "SELECT type FROM [model]"
Set cbofields(0).RowSource = AdoType
Set grdDataGrid.DataSource = adoPrimaryRS
mbDataChanged = False
End Sub
When i open the form, by default the datagrid will display all the records, but the problem is, when i select on the datacombo, the datagrid didn't display the relevant record.
The problem is, it displays all the records.
Any idea? thanx in advance..