From: Gilgamesh on
On Mar 26, 11:24 pm, "Albert D. Kallal"
<PleaseNOOOsPAMmkal...(a)msn.com> wrote:
> 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...(a)msn.com

Rich, Albert,

Thanks for your help on this. I bit the bullet and wrote code based
on your examples. It worked right away - within minutes of my
starting. Problem solved.
I decided to add a file open dialog - that took hours to get right.
Each time I googled for an example of how to do it I got a different
example which always had something missing and would not compile.

Eventually I found the best example code to open a file open dialog on
Microsoft's website - it worked right away.

I think some of my problem was that Visual Basic for Access is
different from Visual Basic, compounded by my sometimes finding code
for later or earlier versions of Access - I have Access 2003.

But thanks again.

To follow on from your other comments, I was expecting a way to run
files of SQl because my introduction SQL and databases was using
things like Orace, Informix, etc, which all have such a capability.
In fact I had only ever typed SQL straight into a window or written it
into a file then run the file - I had never used a tool which built
the query for you and I found it hard at first to use the Access Query
Design View. Now I've got used to using Access I think it's great.
It is easy to do some things very quickly and easily. For my uses it
is fast enough.

I did not want to start using Visual Basic because, in the past, I
have had to become proficient in several Assembly languages, Algol,
Fortran, Ada, C, C++, various shell and scripting languages, and
probably some I've forgotten. I have just had a ten year break from
programming, so the idea of learning another programming language was
not too appealing. Now I've made the leap, it's not so bad.

Bye.

Mike