Results 1 to 8 of 8

Thread: ms report without the database(ms access)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2008
    Posts
    164

    ms report without the database(ms access)

    is there anyway i can make my msflexgrid and my textboxes and label boxes.... etc. to the msaccess report table without using a database? i am using vb6... btw... tnx in advance... ^_^

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,515

    Re: ms report without the database(ms access)

    You can load the data from the grid into a recordset and use that recordset as the reports datasource.

    Code:
    Dim rsU As New ADODB.Recordset, rsG As New ADODB.Recordset
    Dim rsR As New ADODB.Recordset
        
        With rsR
            ' Create Recordset Fields (Columns) here
            .Fields.Append "userid", adVarChar, 12
            .Fields.Append "name", adVarChar, 50
            .Fields.Append "addr1", adVarChar, 50
            .Fields.Append "addr2", adVarChar, 50
            .Fields.Append "csz", adVarChar, 35
            .Fields.Append "acres", adDouble
            .CursorType = adOpenKeyset
            .LockType = adLockOptimistic
            .Open
            .Sort = "acres"
        End With
        
        rsU.Open "select * from users order by userid", conCnn, adOpenKeyset, adLockReadOnly, adCmdText
        With rsU
            Do While Not .EOF
                rsG.Open "select sum(grossacres) as acres from lots where userid='" + !userid + "' or ownerid='" + !userid + "'", conCnn, adOpenKeyset, adLockReadOnly, adCmdText
                rsR.AddNew
                rsR!userid = !userid
                rsR!Name = !Name
                rsR!Addr1 = !Addr1
                rsR!Addr2 = !Addr2
                rsR!csz = Trim(!City) + ", " + !State + " " + !zip
                rsR!acres = IIf(IsNull(rsG!acres), 0, rsG!acres)
                rsR.Update
                Set rsG = Nothing
                .MoveNext
            Loop
        End With
        Set rsU = Nothing
        With rptUserowneracreage
            Set .DataSource = rsR
            .DataMember = rsR.DataMember
            .Show vbModal
        End With
    This example doen't use a grid but it can easily be modified, just cycle thru the grid and add the data to the new recordset.

  3. #3
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: ms report without the database(ms access)

    This "msaccess report table without using a database?" is confusing. If there is no database then how could you set data to an MS Access report? Or did I misunderstood you?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Dec 2008
    Posts
    164

    Re: ms report without the database(ms access)

    lol, thats exactly my point, how will you do it?!... lately i have been having alot of ideas on how will you do this kind of things... i need only an idea or a hint perhaps..

    wes4bt, it is still accessing the database, tnx for the reply guys, i really appreciate it.... but still the answer to my question is not resolved... ^_^

  5. #5
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,515

    Re: ms report without the database(ms access)

    If you load the recordset using your msflexgrid then you don't need to access a database, the code is just an example. hint, hint

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Dec 2008
    Posts
    164

    Re: ms report without the database(ms access)

    OH, can you load a recordset without a destination? what a clever idea, as i think about your hint, it is possible.... i'll try and experiment.... good hint....

    Edit: hmmmm.... but your hint up there is still making a table for access, i mean no table as i need only the report.... i still dont get it....
    Last edited by ungas023; Feb 1st, 2009 at 12:43 AM.

  7. #7
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,515

    Re: ms report without the database(ms access)

    This is what I'm talking about,
    Code:
    Dim rsR As New ADODB.Recordset, i As Integer
        
        With rsR
            ' Create Recordset Fields (Columns) here
            .Fields.Append "somedata", adVarChar, 12
            .Fields.Append "moredata", adVarChar, 50
            .CursorType = adOpenKeyset
            .LockType = adLockOptimistic
            .Open
            .Sort = "somedata"
        End With
        
        With MSFlexGrid
            For i = 0 To .Rows - 1
                rsR.AddNew
                rsR!somedata = .TextMatrix(i, 1)
                rsR!moredate = .TextMatrix(i, 2)
                rsR.Update
            Next i
        End With
        
        With DataReport1
            Set .DataSource = rsR
            .DataMember = rsR.DataMember
            .Show vbModal
        End With
    There isn't a database necessary for this.

    I'm curious how you plan to fill the MsFlexGrid in the first place.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Dec 2008
    Posts
    164

    Re: ms report without the database(ms access)

    will try that later. . . tnx. . .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width