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!

How do I use a string as output in a form???? PLEASE HELP!!!!!!!!

Status
Not open for further replies.

UWTechie

Programmer
May 24, 2001
18
0
0
CA
This is the code that I have which will get the sql from all the queries in a table, and then put it into a string

Sub sqlRetriever

Dim qDef As QueryDef
Dim sqlString As String
Dim qCnt As Integer
qCnt = CurrentDb.QueryDefs.Count



For i = 0 To (2)

Set qDef = CurrentDb.QueryDefs(i)
sqlString = sqlString + (qDef.Name + Chr(13))
sqlString = sqlString + (qDef.SQL + Chr(13) + Chr(13))

Next i

End Sub

I need to get the sqlString into a form, so that I can then export it to Excel, but linking to the form itself... But I HAVE NO IDEA how to get the string into the form... Not a bloody clue... I have tried everything...

ObjectName.Print sqlString, Me.txtSql = sqlString, etc...

Nothing has worked... Please help me, and try to be very explicit in what I should do, because i have never used VB before... thank you very much....
 
I made a couple of changes:

Code:
Sub sqlRetriever()

Dim qDef As QueryDef
Dim sqlString As String
Dim qCnt As Integer
Dim i As Integer
qCnt = CurrentDb.QueryDefs.Count - 1



For i = 0 To qCnt
    
    Set qDef = CurrentDb.QueryDefs(i)
    sqlString = sqlString + (qDef.Name + Chr(13))
    sqlString = sqlString + (qDef.SQL + Chr(13) + Chr(13))
    Debug.Print sqlString
Next i


End Sub

If you go to your debug window (Ctl + G in a module), you'll see the name of evry query in your database and it's accosicated SQL statement.

Now, what I don't understand, is what you're trying to do with this ??? Tyrone Lumley
augerinn@gte.net
 
This is to have a way doing some documentation.;.. Basically, it all has to do with when someone makes a link from Excel to a query, and that link is then broken... What we want is to be able to bring all the SQL code to the spreadsheet, so that we can duplicate it if the .mdb disappears... Thing is that my boss wants it automated...

I knew that I could send it to the debug window, and then get the stuff from there (through cutting and pasting), but is there some way to either send it to a report, form or even a text file, so that then they could link right to that... The basic idea is that when whoever makes the mdb, runs this macro, and then no one else has to actually open the .mdb again... Thus the only contact that someone else would have with the .mdb is when they link to it through Excel, so that they can get to the Queries... But, the thing is that I have no bloody clue as to how to move all this darn text over....
 
Sounds okay, but is there any way to do it without cutting and pasting?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top