report recordsource does "not exist"

HappyYN

"Invalid outside procedure"
-------------------
In your third last post on the first page: -

Public searchSQL As String
searchSQL = "SELECT ,blah, blah, blah…

Then in your first post on the second page: -

"after your reply I put it in the declarations section of a module"
-------------------

You can not initialise a variable outside a procedure, so "searchSQL = "SELECT ,blah, blah, blah…" must be in a Sub or Function. Without going into the SQL itself, because I'm no good at it, may I suggest that wherever the SQL string is built, then that is where the assignment to the Public Variable should be done, within that very same procedure.

You could 'Base load' the SQL searchSQL string with: -

Public Const conSearchSQL As String = "SELECT ,blah, blah, blah…"
Public searchSQL As String

and use it like: -

-------------------

locally to the Procedure in which strMyDynamicAppend is created.

Code:
Private Sub Form_Open(ByRef intCancel As Integer)
    Dim [color=blue]strMyDynamicAppend[/color]  As String
    
    [color=blue]strMyDynamicAppend[/color] = "12345"    [color=green]'  Or whatever.[/color]   
    
    [color=yellow]searchSQL[/color] = [color=red]conSearchSQL[/color] & [color=blue] strMyDynamicAppend [/color]
    
    DoCmd.OpenReport "[color=Blue]rptMyBelligerent[/color]", acViewPreview
    
End Sub
I hope that helps because my spell checker is going ballistic with the formatting.

As an aside, HappyYN.
It's generally not a good idea to post so much code, especially when it's an SQL string.
Although we all know it, but we seldom follow it, we need to reduce a problem in order to solve it... not expand it.

In this case I would suggest creating a small, very small, test SQL string and try passing that first.
Once that has been achieved, start to expand the problem to the point of breakage or total success.
Sounds simple, but it ain't.

That's enough from me, I don't want to muddy the waters…back to bjackson.
(Blood, Sweat and Tears. Good show bjackson.)

Regards
Chris
 
Last edited:
Thanks alot
I'll try it!
You''ve been a great help & source of support
 
Alls well that ends well!

Hooray its working!
bjackson thanks for your samples they really helped me put the right code in the right places
Chriso thanks also for your comments I tried whay you said building up the sql bit by bit and eliminated the error

It just goes to show that this forum is tops!!
Good job you Australians are up while I sweated it out through the night here in England UK!
:) :D ;)
 
glad you got it working,a picture is worth a thousand words when
you are trying to communicate
 

Users who are viewing this thread

Back
Top Bottom