Link to home
Start Free TrialLog in
Avatar of mlcktmguy
mlcktmguyFlag for United States of America

asked on

Data revisions not reflected on the VB 6.0 Report

I am using proprietray file in my app.  I am also using the VB 6.0 Report writer to generate reports.  The following is an example of the code that is executed when the 'print' button is pressed on a given form.  In this case:
the form is 'frmDescription'
the report is 'rptMainInfo'
the record set built to pull information from the form and dynamically bind it to the VB report is called 'rsMainInfo'.

Here is the problem:  Pulling the data from the form and passing it to the report works great unless I change data on the form.  If I print after I have changed data the original contents of the form still print.  If I exit the program, permanently saving the 'new' data' and come back into the form, the report it will print the new data.  Should I be issuing a refresh or repaint command before trying to print a form with revised data?


Public Sub PrintMainInfo(fromPrintButton As Boolean)

Dim rsMainInfo As New ADODB.Recordset

With rsMainInfo
' labels
  .Fields.Append "TargetLabel", adVarChar, 30
  .Fields.Append "ThreatActLabel", adVarChar, 30
  .Fields.Append "ThreatLevelLabel", adVarChar, 30
  .Fields.Append "AdversaryLabel", adVarChar, 30
  .Fields.Append "AdvDedLabel", adVarChar, 30
  .Fields.Append "AdvTacLabel", adVarChar, 30
  .Fields.Append "AdvWeapLabel", adVarChar, 30
  .Fields.Append "DefStratLabel", adVarChar, 30
' data
  .Fields.Append "TargetText", adVarChar, 240
  .Fields.Append "ThreatActText", adVarChar, 240
  .Fields.Append "ThreatLevelText", adVarChar, 240
  .Fields.Append "AdversaryText", adVarChar, 240
  .Fields.Append "AdvDedText", adVarChar, 240
  .Fields.Append "AdvTacText", adVarChar, 240
  .Fields.Append "AdvWeapText", adVarChar, 240
  .Fields.Append "DefStratText", adVarChar, 240
  .Fields.Append "BigText", adVarChar, 2000
  .CursorType = adOpenKeyset
  .LockType = adLockOptimistic
  .Open

  Dim f As New frmDescription
    .AddNew
' labels (but really text boxes on MainInfo Page)
    ![TargetLabel] = f!TargetCap.Text
    ![ThreatActLabel] = f!ThrtActCap.Text
    ![ThreatLevelLabel] = f!ThrtLevCap.Text
    ![AdversaryLabel] = f!AdvsryCap.Text
    ![AdvDedLabel] = f!AdvDedCap.Text
    ![AdvTacLabel] = f!AdvTactCap.Text
    ![AdvWeapLabel] = f!AdvWeapCap.Text
    ![DefStratLabel] = f!DefStratCap.Text
' data
    ![TargetText] = f!DescTarget.Text
    ![ThreatActText] = f!DescThreatAct.Text
    ![ThreatLevelText] = f!DescThreatLev.Text
    ![AdversaryText] = f!DescAdvesary.Text
    ![AdvDedText] = f!DescAdvDed.Text
    ![AdvTacText] = f!DescAdvTact.Text
    ![AdvWeapText] = f!DescAdvWeopons.Text
    ![DefStratText] = f!DescDefStrategy.Text
    ![BigText] = f!Text3.Text
'
    .Update
'
    Set f = Nothing

'
End With
'
With rptMainInfo
  Set .DataSource = rsMainInfo
  .DataMember = rsMainInfo.DataMember
'  .Orientation = 2    ' rptOrientLandscape
  DoEvents
    If PrintEm = True Then
        .PrintReport
    Else
        .Show vbModal
    End If

End With

rsMainInfo.Close
'
Set rsMainInfo = Nothing
'
End Sub
ASKER CERTIFIED SOLUTION
Avatar of fds_fatboy
fds_fatboy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mlcktmguy

ASKER

I don't understand.  Where would I see this option?  When I am editing my report in the designer I don't have that option on my 'File' menu.
Avatar of fds_fatboy
fds_fatboy

Sorry - I made an assumption that it behaved in the same way as Crystal.

It does look very similar to the Crystal design feature option where the data is saved with the report.
Points increase to 500