vb6 - I can not get result every time I run data report . How can I fix this ? -


i want make report of daily income expense account. using data environment report , made date field group field. problem every time run program data appears , sometime it's showing blank. can't understand why happening , reason it? have bind table directly through data environment tool code here

private sub cmdok_click()

dim rsrojmelincome new adodb.recordset
dim rsrojmelexp new adodb.recordset
dim rstemprojmel new adodb.recordset
cn.execute "delete temprojmel"

rsrojmelincome.open " select * rojmel date1 between #" & format(dtpicker1.value, "mm/dd/yyyy") & "# , #" & format(dtpicker2.value, "mm/dd/yyyy") & "# , incexp = 'ytjtf'", cn, adopenkeyset, adlockoptimistic

rsrojmelexp.open " select * rojmel date1 between #" & format(dtpicker1.value, "mm/dd/yyyy") & "# , #" & format(dtpicker2.value, "mm/dd/yyyy") & "# , incexp = 'sjtf'", cn, adopenkeyset, adlockoptimistic

set rstemprojmel = new adodb.recordset

rstemprojmel.open "select * temprojmel", cn, adopenkeyset, adlockoptimistic

if rsrojmelincome.recordcount >= 1 then

for = 1 rsrojmelincome.recordcount rstemprojmel.addnew rstemprojmel.fields("id") = rstemprojmel.fields("incvigat") = rsrojmelincome.fields("vigat") rstemprojmel.fields("date1") = rsrojmelincome.fields("date1") rstemprojmel.fields("incamount") = rsrojmelincome.fields("amount") rstemprojmel.update
rsrojmelincome.movenext
next i
end if

if rsrojmelexp.recordcount >= 1

for j = 1 rsrojmelexp.recordcount rstemprojmel.addnew rstemprojmel.fields("id") = j rstemprojmel.fields("expvigat") = rsrojmelexp.fields("vigat") rstemprojmel.fields("date1") = rsrojmelexp.fields("date1") rstemprojmel.fields("expamount") = rsrojmelexp.fields("amount") rstemprojmel.update
rsrojmelexp.movenext
next j
end if

if dataenvironment1.rscommand1_grouping.state = 0

dataenvironment1.rscommand1_grouping.open " shape {select * temprojmel} command1 compute command1, sum(command1.'incamount') aggregate1, sum(command1.'expamount') aggregate2,calc (aggregate1-aggregate2) netprof1 'date1' ", dataenvironment1.connection1, adopenkeyset, adlockoptimistic

end if

rptrojmel.sections("section7").controls.item("text1").datafield = dataenvironment1.rscommand1_grouping.fields("netprof1").name

rptrojmel.sections("section7").controls.item("text2").datafield = dataenvironment1.rscommand1_grouping.fields("aggregate1").name

rptrojmel.sections("section4").controls.item("lbldate1").caption = dtpicker1.value

rptrojmel.sections("section4").controls.item("lbldate2").caption = dtpicker2.value

rptrojmel.refresh
dataenvironment1.rscommand1_grouping.requery
rptrojmel.refresh
end sub

instead of

if dataenvironment1.rscommand1_grouping.state = 0    dataenvironment1.rscommand1_grouping.open " shape {select *      temprojmel} command1 compute command1, sum(command1.'incamount') aggregate1, sum(command1.'expamount') aggregate2,calc (aggregate1-aggregate2) netprof1 'date1' ", dataenvironment1.connection1, adopenkeyset, adlockoptimistic  end if 

try using

if dataenvironment1.rscommand1_grouping.state = adstateopen    dataenvironment1.rscommand1_grouping.close  end if  dataenvironment1.rscommand1_grouping.open " shape {select *      temprojmel} command1 compute command1, sum(command1.'incamount') aggregate1, sum(command1.'expamount') aggregate2,calc (aggregate1-aggregate2) netprof1 'date1' ", dataenvironment1.connection1, adopenkeyset, adlockoptimistic 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -