Solved

Data revisions not reflected on the VB 6.0 Report

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…

770 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