![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
Hi, Could display a sample of what the sql in the text file looks like? *It is unclear what you are describing. *I am picturing something like select fld1, fld2, fld3, fld4, fld5, .., fld100 from tbl1 t1 join tbl2 t2 on t1.ID = t2.ID where some condition exists. If it is something like this then the easiest approach would be to read the textfile into the mdb and then create a sql string from the text you just read in. *Here is how to read from a textfile in VBA Sub ReadTxtFile() * *Dim strTxt * *Open "C:yourTxtFile.txt" For Input As #1 * *Do While Not EOF(1) * * * Line Input #1, strTxt * * * Debug.Print strTxt * *Loop * *Close #1 End Sub Rich *** Sent via Developersdexhttp://www.developersdex.com*** |

#4
| |||
| |||
|
#5
| |||
| |||
|
#6
| |||
| |||
|
|
Just write a little routine that opens up the sql and runs it. eg: Sub SqlScripts() * *Dim vSql() * * As String * *Dim vSqls * * *As Variant * *Dim strSql * * As String * *Dim intF * * * As Integer * *intF = FreeFile() * *Open "c:\sql.txt" For Input As #intF * *strSql = Input(LOF(intF), #intF) * *Close intF * *vSql = Split(strSql, ";") * *On Error Resume Next * *For Each vSqls In vSql * * * CurrentDb.Execute vSqls * * * Debug.Print "--->" & vSqls * *Next End Sub I suppose you could add 2-3 more lines to the above to pop open the file dialog to browse to the sql file if it was to be changed a lot. -- Albert D. Kallal * *(Access MVP) Edmonton, Alberta Canada pleaseNOOSpamKal... (AT) msn (DOT) com |
![]() |
| Thread Tools | |
| Display Modes | |
| |