Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display SQL statement into a text field on a report

Status
Not open for further replies.

vanuta

MIS
Feb 13, 2001
13
0
0
US
I have a report that is coming from a query called "PO Query". In the query there is multiple criteria:

PODte Between #1/1/99# and #12/31/99# and PoNumber Between 100 and 1200051

I want to display the where clause of the sql statement in a textbox on my report. Is there an easy way to do this????

Any help would be appreciated!
 
Maybe put this code in the OnLoad event of the report.

Dim sSQL As String
sSQL = Me.RecordSource
Me.textboxname.Value = sSQL

I dunno, I haven't tried it, but it might work.
 
This works to just display the WHERE part of the SQL Statement.

Private Sub PageHeaderSection_Print(Cancel As Integer, PrintCount As Integer)
Dim sSQL As String
Dim cutat As Long

sSQL = Me.RecordSource
cutat = InStr(sSQL, "WHERE")
If cutat = 0 Then
'WHERE is not in the SQL Statement
Me.txtSQL.Value = sSQL
Else
'WHERE's in there
'Will replace WHERE with itself, but this will accomplish dropping the rest of the string that you don't want.
sSQL = Replace(sSQL, "WHERE", "WHERE", cutat)
Me.txtSQL.Value = sSQL
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top