hi,
Application in
VB 6, ADO 2.0
Event is double click List1
Database : Access
Flow - select a Number (from datacombo1.text) and display the connected transaction(table) in datagrid.
number is selected from datacombo1.text(connected to ADODC1.recordset) and connected transaction record is displayed in datagrid.
To Add, double Click - list box and Item from list box are added to transaction table.
For first top item selected from datacombo1.text, it adds properly the connected item selected from list box also displays it correctly in datagrid i.e. just below the existing transaction of the datagrid.
Everything is fine on adding the record from list box, for the first top item selected from datacombo1.text and also displays correctly in datagrid.
[red]Error:
when adding new transaction for the second or third or ..... items selected from datacombo1.text.
It correctly adds the new record in the transaction table(selected from list box), only thing is, does not display record it in datagrid with new record added to transaction table at runtime.
(what it shows in the datagrid is the transaction of the first item of datacombo1.text)
Only after closing the form and restarting the form it displays the record correctly. [/red]
Adodc1.recordset
Most Variables are declared public
[red]shape {select COID,No,IDate,TDate,Rate, GrossAmt from Master order by No} as ParentCMD
APPEND ({select t_no as no,t_sno,t_itUnit,t_qty,t_rate,t_amt as Amt from Tran order by t_sno,t_hno } as CHILDCMD
RELATE No to no) as childcmd[/red]
[blue]public sub dGrid
Adodc1.Refresh
Adodc1.Recordset.Requery
Set DataGrid1.DataSource = Adodc1.Recordset("ChildCMD".UnderlyingValue
end sub[/blue]
private sub list1_dblClick
Dim i As Integer
Dim j As Integer
Dim sqlSt As String
Dim lth As Integer
Dim vlth As Integer
For i = 0 To List1.ListCount - 1
If List1.Selected(i) = True Then
vlth = 1
lth = Len(List1.List(i))
Do While lth <> 0
If MID(List1.List(i), vlth, 1) = "/" Then
Exit Do
Else
vt_itid = Trim(MID(List1.List(i), 1, vlth))
vlth = vlth + 1
Debug.Print Text2.Text
End If
lth = lth - 1
Loop
vlth = Len(Text2.Text)
For j = 0 To List2.ListCount - 1
If Trim(MID(List2.List(j), 1, vlth)) = Text2.Text Then
vsno = vsno + 1
vTextData = List2.List(j)
vlthText = Len(vTextData)
' to check whether the recordset is
' transferred properly
Debug.Print "vTextData " & vTextData
' for transferring value from vTextData
' to each variable
Call trfValue
vTotal = vRate * vMMnt
[red]sqlSt = "insert into Tran(t_no,t_sno,t_itid,t_qty,t_rate,t_Amt) "
sqlSt = sqlSt & "values ('" & vNo & "','" & vSno & "','" & vt_itid & "','" & vt_qty & "," & vRate & "," & vTotal & ""
cn.Execute (sqlSt)[/red]
Exit For
End If
Next
End If
call Dgrid
Call dispColumn ' - displays data in formatted datagrid
Next
End Select
end sub
Thanks,
Lad