Hi all,
how to insert correct value from ms access database to data report label ?
my report as below, only last one is correct.
the left side red box(label16,label17) value must match with total target and total sales on the right side red box.
Code:
Dim RS1 As New ADODB.Recordset
Dim CN1 As New ADODB.Connection
Public INC As Currency
Public Incen As Currency
Public IncenT As Currency
Private Sub btnview_Click()
If MsgBox(" View Report?", vbYesNo, "View Report") = vbYes Then
incentiveReport.Orientation = rptOrientLandscape
DataEnvironment4.Commands(1).CommandText = "select * from incentive where name1 Like '" & nametxt & "%'"
CalIncentive
CalIncentive1
incentiveReport.Sections("Section1").Controls("Label16").Caption = Incen
incentiveReport.Sections("Section1").Controls("Label17").Caption = INC
incentiveReport.Show
Load DataEnvironment4
With DataEnvironment4
If .rsCommand1.State <> 0 Then .rsCommand1.Close
.Command1
End With
Else
Cancel = 1
End If
End Sub
Code:
Sub CalIncentive1()
RS1Check
RS1.Open "Select totaltarget From incentive where name1 like '" & nametxt & "%'", cn8, adOpenDynamic, adLockPessimistic
While RS1.EOF = False
If Not IsNull(RS1.Fields(0)) Then
Incen = RS1.Fields(0)
End If
RS1.MoveNext
Wend
End Sub
Code:
Sub CalIncentive()
RS1Check
RS1.Open "Select totalsales from incentive where name1 like '" & nametxt & "%'", cn8, adOpenDynamic, adLockPessimistic
While RS1.EOF = False
If Not IsNull(RS1.Fields(0)) Then
INC = RS1.Fields(0)
End If
RS1.MoveNext
Wend
End Sub