Solved

Data revisions not reflected on the VB 6.0 Report

Posted on 2004-10-19
4
234 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
  • 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now