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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Building Code at Run-Time

Status
Not open for further replies.

JimCowan

Technical User
Jul 12, 2000
10
CA
Is it possible to generate a line of code during run-time. I want to delete files depending upon a prior calculation. Can it be done?
 
Yes, building SQL code at runtime is done all the time. Set your basic code to a string then interweave the elements that change depending on your circumstances. Here's an example deleting all incidents in FileName where the ID is above the Limit. FileName and Limit can be set at runtime.

Dim strSQL as string
Dim FileName as string
FileName "MyFile"
Limit = 56

strSQL = "DELETE " & FileName & ".*," & FileName & ".ID FROM " & FileName & "WHERE (((" & FileName & ".ID)>" & Limit & "));"

Docmd.RunSQL strSQL

Uncle Jack

 
IMHO, neither of these actually 'build' anything. each is a manner of selecting from choices.

It IS possible to actually create code during run time, Refer to "Modules" in help, then review the InsertLines (et al) Method.

I would say that this is SLEDOM done in MS. Access - or any modern language for production applications. The use of this and related techniques were once-upon-a-time common, but are generally discouraged on several grounds, not the least of which is the trouble with debugging code that doesn't exist.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top