Here's my code:
I'm using VB6, ADODB, and MsAccess as for the database.
Using the combobox as the key to display all of records from the table.
For NoProd = Prod001 has 3 records : candybar, chocolate, sweets
When i change the combobox of NoProd to Prod001,
But why my datagrid show only candybar?
Private Sub cboSKP_Click()
Dim rs6 As New ADODB.Recordset
With rs6
.ActiveConnecti on = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & NmDatabase & ";Persist Security Info=False"
.CursorLocation = adUseClient
.LockType = adLockOptimisti c
.CursorType = adOpenStatic
.Source = "SELECT * FROM Products WHERE NoProd = '" & cboProd.Text & "'"
.Open
If cboProd.ListInd ex > -1 Then
cboCust.Text = rs6(3)
Dim rs8 As New ADODB.Recordset
With rs8
.ActiveConnecti on = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & NmDatabase & ";Persist Security Info=False"
.CursorLocation = adUseClient
.LockType = adLockOptimisti c
.CursorType = adOpenStatic
.Source = "SELECT * FROM Ms_Cust WHERE Code = '" & cboCust.Text & "'"
.Open
If cboCust.Text = rs6(3) Then
lblSalesMan.Cap tion = rs8(8)
lblCompName.Cap tion = rs8(1)
lblAdd.Caption = rs8(2)
End If
cboTerm.Text = rs6(4)
txtDue.Text = rs6(5)
End With
If cboProd.Text = rs6(0) Then
rs(0).Value = rs6(6)
rs(2).Value = rs6(7)
End If
End If
.Close
End With
End Sub
Dim rs6 As New ADODB.Recordset
With rs6
.ActiveConnecti on = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & NmDatabase & ";Persist Security Info=False"
.CursorLocation = adUseClient
.LockType = adLockOptimisti c
.CursorType = adOpenStatic
.Source = "SELECT * FROM Products WHERE NoProd = '" & cboProd.Text & "'"
.Open
If cboProd.ListInd ex > -1 Then
cboCust.Text = rs6(3)
Dim rs8 As New ADODB.Recordset
With rs8
.ActiveConnecti on = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & NmDatabase & ";Persist Security Info=False"
.CursorLocation = adUseClient
.LockType = adLockOptimisti c
.CursorType = adOpenStatic
.Source = "SELECT * FROM Ms_Cust WHERE Code = '" & cboCust.Text & "'"
.Open
If cboCust.Text = rs6(3) Then
lblSalesMan.Cap tion = rs8(8)
lblCompName.Cap tion = rs8(1)
lblAdd.Caption = rs8(2)
End If
cboTerm.Text = rs6(4)
txtDue.Text = rs6(5)
End With
If cboProd.Text = rs6(0) Then
rs(0).Value = rs6(6)
rs(2).Value = rs6(7)
End If
End If
.Close
End With
End Sub
Using the combobox as the key to display all of records from the table.
For NoProd = Prod001 has 3 records : candybar, chocolate, sweets
When i change the combobox of NoProd to Prod001,
But why my datagrid show only candybar?
Comment