Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 26th, 2004, 01:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default Report's record source too long

I have a Access 97 that I am working with (not able to upgrade for politicle reasons) and I am trying to set the Record Source of a report to a text box control on a form and I get that an error saying the string is too long.

If I copy and past the SQL code into the Record Source I get: "the text is too long to be edited"

The SQL code is about 2000 characters in total length.

How the heck do I set the reports record source to my SQL string?

I can't make a query and save it, because the report is based on an SQL statment that I create in code based on a bunch of selections "From" and "Thru" on a form, so it is all generated on the fly?
__________________
Mitch
 
Old January 26th, 2004, 01:11 PM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Set the reports recordsource to an ADO (or DAO) Recordset instead. Use the same string as the source of the recordset.

Hope that works.



Sal
 
Old January 26th, 2004, 01:28 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sal, would I do that in code on the reports On Open event, and have that code reference the from's controls?
 
Old January 26th, 2004, 01:41 PM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default

On the Report's Open Event. you oipen your recordset and set the recordsource of the report:

me.recordsource = rs
or
me.recordset = rs

one of the two.






Sal
 
Old January 26th, 2004, 02:16 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sal, I get erros either way. Here is what I am trying, the first part is the old way that worked, but not with long strings, the error messages for your suggestions farther down. I used the DAO approach:

'***The below works, but only for smaller strings
'Me.RecordSource = Forms!F_ToolingTypeSelectionForReport!tbxSQL_Strin g
'Me.tbxCriteria.caption = Forms!F_ToolingTypeSelectionForReport!tbxLable_Str ing
'************************************************* **********
Me.tbxCriteria.caption = "TEST"
'MsgBox "The report's record sources is: " & Forms!F_ToolingTypeSelectionForReport!tbxSQL_Strin g

Dim dbs As Database, rst As Recordset, strSQL As String



    Set dbs = CurrentDb()
    strSQL = Forms!F_ToolingTypeSelectionForReport!tbxSQL_Strin g

    Set rst = dbs.OpenRecordset(strSQL)

    If rst.BOF = True Then
            MsgBox "No Detail found!"

    ElseIf rst.BOF = False Then
        'Me.Recordset = rst '**Gives me: Method or data Member Not Found
        Me.RecordSource = rst '**Gives me: Type Mismatch

    End If

    rst.Close
    Set dbs = Nothing
 
Old January 26th, 2004, 03:49 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Mitch

You've got two possibilities here:

1. Build and run your query, and turn the results into a list suitable for use as a combo box source. This only works if the resultset of the query is reasonably short.

2. Build your SQL and then temporarily create a saved query based on this.

Let us know which would be best.


Brian Skelton
Braxis Computer Services Ltd.
 
Old January 26th, 2004, 04:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

(Opps, it is not Sal, sorry about that.)
Braxis,

 I think option 2 will work for my needs.
 
Old January 26th, 2004, 04:17 PM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Or maybe build your string in a string Variable. Then use that string variable to open a recordset. Creating a Query at run time can cause problems.



Sal





Similar Threads
Thread Thread Starter Forum Replies Last Post
SOLVED - VBA Help For Row Source and Record Source eusanpe Access VBA 4 May 13th, 2008 11:58 AM
record.source WHERE date comparison Richard Lally Access 3 January 5th, 2006 08:03 PM
Update Source Record After Insert Duncan Allen SQL Server DTS 1 October 25th, 2004 10:44 AM
Record source ... does not exist tunsted Access 2 April 1st, 2004 10:03 AM
record source damnnono_86 Access 6 November 10th, 2003 10:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.