Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Suite Pro
  New Posts New Posts RSS Feed - Reports: LoadSettings Error
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Reports: LoadSettings Error

 Post Reply Post Reply
Author
Message
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post Topic: Reports: LoadSettings Error
    Posted: 12 January 2005 at 11:19am
I keep getting an error when I use the LoadSetting method ("method of object...failed).  Is there any documentation out there besides what little bit is in the help file?
Back to Top
dlord View Drop Down
Newbie
Newbie


Joined: 25 October 2004
Location: United States
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote dlord Quote  Post ReplyReply Direct Link To This Post Posted: 12 January 2005 at 7:36pm

It works good for me. Here is a clip of the code for Save and Load. Enjoy -

Private Sub cmdSaveReport_Click()
SaveFilename = tbSaveFilename.Text
SaveFilename = Trim(SaveFilename)
If Not IsNull(SaveFilename) Then
SaveFilename = App.Path & "\" & SaveFilename

    Dim FreeF As String
    FreeF = FreeFile
    'Kill sFile
    Open SaveFilename For Binary As #FreeF
    Put #FreeF, , frmReport.wndReport.SaveSettings
    Close #FreeF
   
End If
End Sub

Private Sub File1_Click()
Dim LoadFileName As String
LoadFileName = App.Path & "\" & File1.FileName
Dim sLayout As String
Dim FreeF As String
        FreeF = FreeFile
        sLayout = Space(FileLen(LoadFileName))
        Open LoadFileName For Binary As #FreeF
        Get #FreeF, , sLayout
        Close #FreeF
        On Error GoTo 0
        frmReport.wndReport.LoadSettings sLayout
End Sub

Back to Top
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post Posted: 13 January 2005 at 11:35am

That's pretty much the exact same code I'm using, without any luck.

Is it possible that my property settings for the report control might impact this?  For example, the various edit settings, etc.

Thanks!

Dan

Back to Top
dlord View Drop Down
Newbie
Newbie


Joined: 25 October 2004
Location: United States
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote dlord Quote  Post ReplyReply Direct Link To This Post Posted: 13 January 2005 at 5:42pm

Humm, I'm not sure.

Are there any other signs of problems with your report performing other functions.

Is that the whole error message...?

Sorry that didn't help

Back to Top
ianp View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 19 December 2003
Location: United Kingdom
Status: Offline
Points: 119
Post Options Post Options   Thanks (0) Thanks(0)   Quote ianp Quote  Post ReplyReply Direct Link To This Post Posted: 13 January 2005 at 7:11pm

Hi Dan - any chance you can post your code?

Also, I've come across this error if the number (and order of) columns added to the control, does not correspond to the column configuration in the settings string...

Back to Top
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post Posted: 13 January 2005 at 9:03pm

Here's the code used to save/load the report settings (note that the code verify's whether a file has already been created to save the settings for the particular report):

Private Sub SaveReportSettings(sType As String)

    Dim FreeF As Integer, sFile As String, sLayout As String
   
    sFile = App.Path & "\" & sType & ".000"
    FreeF = FreeFile
    If VerifyFile(sFile) Then
        Kill sFile
    End If
    Open sFile For Binary As #FreeF
    Put #FreeF, , frmMain.wndReportControl.SaveSettings
    Close #FreeF

End Sub
Private Function LoadReportSettings(sType As String) As Boolean
   
    Dim FreeF As Integer, sFile As String, sLayout As String

    If VerifyFile(App.Path & "\" & sType & ".000") Then
        On Error GoTo LoadReportSettings_Error
        sFile = App.Path & "\" & sType & ".000"
        FreeF = FreeFile
        sLayout = Space(FileLen(sFile))
        Open sFile For Binary As #FreeF
        Get #FreeF, , sLayout
        Close #FreeF
        frmMain.wndReportControl.LoadSettings sLayout
    Else
        Exit Function
    End If
    LoadReportSettings = True
    Exit Function
LoadReportSettings_Error:
    Err.Clear
    Exit Function
End Function

Here's the code setting up the report:

Private Sub CreateItemReport(sFilter As String)
   
    Dim Column  As ReportColumn
    Dim lIndex  As Long
   
    With frmMain.wndReportControl.Columns
        Set Column = .Add(lIndex, "Item ID", 4, True)
        lIndex = lIndex + 1
        Column.Visible = False
        Set Column = .Add(lIndex, "Subject", 60, True)
        lIndex = lIndex + 1
        Set Column = .Add(lIndex, "Description", 100, True)
        lIndex = lIndex + 1
        Column.Visible = False
        Set Column = .Add(lIndex, "Type", 6, True)
        lIndex = lIndex + 1
        Column.Visible = False
        Set Column = .Add(lIndex, "Start Time", 20, True)
        lIndex = lIndex + 1
        Column.Alignment = xtpAlignmentRight
        Set Column = .Add(lIndex, "End Time", 20, True)
        lIndex = lIndex + 1
        Column.Visible = False
        Column.Alignment = xtpAlignmentRight
    End With

    'Add Records to the ReportControl
    ProcessItemRS sFilter, g_sItem

End Sub

Here's the code writing the data to the report:

Private Sub AddItemRecord(objItem As Object, lItemID As Long, sID As String, _
    lItemID As Long)
 
    Dim Record               As ReportRecord
    Dim Item         &n bsp;      As ReportRecordItem
    
   Set Record = frmMain.wndReportControl.Records.Add()
   
    With Record
        .Tag = sID
        .AddItem lItemID
        .AddItem objItem.Subject
        .AddItem objItem.Description
        .AddItem objItem.Type
        .AddItem objItem.StartTime
        .AddItem objItem.EndTime
    End With
   
End Sub

Hopefully, this helps.  Let me know if you need any add'l info.

Thanks!

Back to Top
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post Posted: 30 January 2005 at 12:40pm

Maybe I'll try to jumpstart this again...

I think the problem might relate to what I expect the LoadSettings/SaveSettings methods do.  I had thought that we (the developer) could create a report in code, adding columns to the report as well as determining which columns would be visible the first time the user views the report.  Once the user has viewed the report, and added or deleted available columns from the view to meet their (the user's) needs, we could then save the user's "settings" and therefore NOT have to load the columns the next time around, just the data.  The user's column settings (which columns are visible, how they are aligned, etc.) would thereby be maintained from one session to the next.  The columns available to the user will always stay the same...just which ones are visible, the widths, alignment, etc., would change from session to session.

Am I thinking this through correctly?

Back to Top
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post Posted: 30 January 2005 at 1:02pm

OK.  I talked my way through it and figured it out.  As noted above, I had thought that the Load/Save Settings methods removed the need to even load the columns each time the user opened a report.  The key is that these methods load and save column "settings" vs. the column "definitions" (for the lack of a better word to use).  Once I started loading the definitions again, before running the LoadSettings method, it works beautifully  Tongue  with all of the appropriate "settings" in place.

Maybe I'm just slow, but I don't think the documentation was really helpful here.  That's OK.  I still like the tools.

Hug

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.