Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

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
0
mlcktmguy
Asked:
mlcktmguy
  • 2
  • 2
1 Solution
 
fds_fatboyCommented:
In your report: I believe you have saved the rpt file with File/SaveWithData set. Try unchecking it and saving it again.
0
 
mlcktmguyAuthor Commented:
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.
0
 
fds_fatboyCommented:
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.
0
 
mlcktmguyAuthor Commented:
Points increase to 500
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now