Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in displaying the datagrid records at runtime.

Status
Not open for further replies.

Cap2010

Programmer
Mar 29, 2000
196
CA

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) = &quot;/&quot; 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 &quot;vTextData &quot; & vTextData

' for transferring value from vTextData
' to each variable
Call trfValue

vTotal = vRate * vMMnt

[red]sqlSt = &quot;insert into Tran(t_no,t_sno,t_itid,t_qty,t_rate,t_Amt) &quot;
sqlSt = sqlSt & &quot;values ('&quot; & vNo & &quot;','&quot; & vSno & &quot;','&quot; & vt_itid & &quot;','&quot; & vt_qty & &quot;,&quot; & vRate & &quot;,&quot; & vTotal & &quot;)&quot;
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
 
Hello Lad,

I don't have an answer to your problem, (I wonder if it still is a problem after all this time!!)

But, I noticed that you are are specidifcally binding the dgrid to an ado data control.

WOuld you know if it is possible to bind a dgrid to an ADO recordset object?

I get an error everytime I do - 'COuldn't bind to %recordset variable name%'

Is this something that just can't be done? I have not seen any examples of binding a dgrid to a Recordset in the MSDN.

Thx
 
hi,
not yet, what i do is close the form and restart the form

Thanks,
cap
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top