ChrisO
Registered User.
- Local time
- Today, 14:00
- Joined
- Apr 30, 2003
- Messages
- 3,202
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.
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
"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
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: