Solved

Data revisions not reflected on the VB 6.0 Report

Posted on 2004-10-19
4
240 Views
Last Modified: 2010-05-02
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
Comment
Question by:mlcktmguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
fds_fatboy earned 500 total points
ID: 12356034
In your report: I believe you have saved the rpt file with File/SaveWithData set. Try unchecking it and saving it again.
0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 12359224
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
 
LVL 10

Expert Comment

by:fds_fatboy
ID: 12367833
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
 
LVL 1

Author Comment

by:mlcktmguy
ID: 12397261
Points increase to 500
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using "ScreenUpdating" 6 86
clicking a shape in a frame array vb6 3 55
Macro problems with Excel file 6 52
Win 10 Automation Error with .doCmd in Access 2 90
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question