Solved

Bug Activating .orientation property on VB6 report

Posted on 2004-11-01
425 Views
Last Modified: 2008-03-06
This is code taken from an App in which I am printing VB 6.0 datsheet reports from a form.

With rptCoverSheet2
  Set .DataSource = rsCoverSheet
  .DataMember = rsCoverSheet.DataMember
  DoEvents
    If PrintEm = True Then
'        .Orientation = PickedOrientation
        .PrintReport
    Else
        .Show vbModal
    End If
 
End With

Notice that the line
.Orientation = PickedOrientation
 is commented.

The variable PickedOrientation is set in another module and I verfied that it is set correctly.  Here's my dilemma.  I inserted this code and tested this module successfully.  The line was working perfectly to set the orientation of the printed output.  Thinking I had this issue reolved I exited VB completely.  Later in the day I was going to create an EXE to deliver to my client.  Amazingly the statement which had compiled before was giving me a compile error even though I had made absolutely no changes.  After much time and the efforts of my parter, he discovered the key.  If while in VB development environment, the datasheet report 'rptCoverSheet2' was opened, the .orientation line would compile and function correctly.  No changes to the report were required.  The report could be opened and then immediately closed again.  An .EXE created at this point functioned correctly.  Once I exited VB and re-entered the line would not compile until I opened and the closed the report.

Can anyone explain this?  It really sounds like something to report to MicroSoft.



'
0
Question by:mlcktmguy
    5 Comments
     
    LVL 69

    Expert Comment

    by:Éric Moreau
    I would suggest that you reinstall VB SP (you need at least SP4 to use this property).
    0
     
    LVL 1

    Author Comment

    by:mlcktmguy
    I have SP6 installed
    0
     
    LVL 69

    Accepted Solution

    by:
    have you tried to reinstall it?
    0
     
    LVL 1

    Author Comment

    by:mlcktmguy
    Sorry, I wasn't clear.  Yes I did reinstall it.  Still got the same situation.
    0
     
    LVL 1

    Author Comment

    by:mlcktmguy
    emoreau,
    Thanks for your interest in my problem.  I did some more research and found the following.
    Apparently I have a know problem because it is mentioned on the knowledgebase.  I quote it below:

    "When you use this new Orientation property in Visual Studio 6.0 Service Pack 4, you may encounter the error below:

    Compiler Error

    Method or Data member not found.

    To fix this error, delete the values for DataMember and DataSource properties of the Data Report and reassign these two properties with the original values."

    This comment seems directly realted to my problem but I have a further dilemma because of the way I am currently generating the file to print the report.

    What do I do with DataMember and DataSource to solve the problem?  When I defined my report all of the fields are unbound and I left DataMember and DataSource blank because I create the recordsets from proprietary file formats directly prior to executing the code which outputs the reports.  I have no Data Enviroment in this project.  An example of my code to create my DataMember and DataSource is below.  I take the fields from the Form and create a recordset then a record.  Finally I bind those fields to the DataReport fields.

    Dim rsCoverSheet As New ADODB.Recordset

    With rsCoverSheet
      .Fields.Append "lbl01", adVarChar, 30
      .Fields.Append "lbl02", adVarChar, 30
      .Fields.Append "lbl03", adVarChar, 30
      .Fields.Append "lbl04", adVarChar, 30
      .Fields.Append "lbl05", adVarChar, 30
      .Fields.Append "lbl06", adVarChar, 30
      .Fields.Append "lbl07", adVarChar, 30
      .Fields.Append "lbl08", adVarChar, 30
      .Fields.Append "lbl09", adVarChar, 30
      .Fields.Append "lbl10", adVarChar, 30
      .Fields.Append "lbl11", adVarChar, 30

      .Fields.Append "RptEvalDate", adVarChar, 20
      .Fields.Append "txt00", adVarChar, 240
      .Fields.Append "txt01", adVarChar, 240
      .Fields.Append "txt02", adVarChar, 240
      .Fields.Append "txt03", adVarChar, 240
      .Fields.Append "txt04", adVarChar, 240
      .Fields.Append "txt05", adVarChar, 240
      .Fields.Append "txt06", adVarChar, 240
      .Fields.Append "txt07", adVarChar, 240
      .Fields.Append "txt08", adVarChar, 240
      .Fields.Append "txt09", adVarChar, 240
      .Fields.Append "txt10", adVarChar, 240
      .Fields.Append "txt11", adVarChar, 240
      .CursorType = adOpenKeyset
      .LockType = adLockOptimistic
      .Open

        Dim f As New frmCoverSheet
        .AddNew
        ![lbl01] = f!FacilCap.Text
        ![lbl02] = f!ParticCap.Text
        ![lbl03] = f!Partic1Cap.Text
        ![lbl04] = f!Partic2Cap.Text
        ![lbl05] = f!SMECap.Text
        ![lbl06] = f!SME01Cap.Text
        ![lbl07] = f!SME02Cap.Text
        ![lbl08] = f!SME03Cap.Text
        ![lbl09] = f!SME04Cap.Text
        ![lbl10] = f!SME05Cap.Text
        ![lbl11] = f!SME06Cap.Text

        ![RptEvalDate] = f!dtPick.Value
        ![txt00] = f!CovText(0).Text
        ![txt00] = f!CovText(0).Text
        ![txt01] = f!CovText(1).Text
        ![txt02] = f!CovText(2).Text
        ![txt03] = f!CovText(3).Text
        ![txt04] = f!CovText(4).Text
        ![txt05] = f!CovText(5).Text
        ![txt06] = f!CovText(6).Text
        ![txt07] = f!CovText(7).Text
        ![txt08] = f!CovText(8).Text
        ![txt09] = f!CovText(9).Text
        ![txt10] = f!CovText(10).Text
        ![txt11] = f!CovText(11).Text
        .Update

        Set f = Nothing
       
    End With
    '
    Printer.Orientation = PickedOrientation
    With rptCoverSheet2
      Set .DataSource = rsCoverSheet
      .DataMember = rsCoverSheet.DataMember
      DoEvents
        If PrintEm = True Then
    '        .Orientation = PickedOrientation
            .PrintReport
        Else
            .Show vbModal
        End If
     
    End With
    '
    rsCoverSheet.Close
    '
    Set rsCoverSheet = Nothing

    Any help would be greatly appreciated.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: Foundations of Front-End Development

    Jump-start a lucrative career in front-end web development, with zero previous coding experience required. This course covers the basic programming concepts and languages required for creating engaging websites from scratch.

    Suggested Solutions

    Title # Comments Views Activity
    Delimit 5 46
    Problem to choose button 2 33
    vlookup from part of the text (filename) 8 41
    Hidden and protected sheets 12 45
    Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
    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…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    933 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

    16 Experts available now in Live!

    Get 1:1 Help Now