Free Lessons
Fast Tips
Topic Index
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
Home > TechHelp > Directory > Access > Database Server 5 < Database Server | Buttons on Reports >
Back to Database Server 5    Comments List
How to send other commands Upload Images   Link   Email  
Jeff Bartuch         
5 months ago
I'm trying to DoCmd.RunSavedImportExport "Import- ImportName".

I have have tried without success:
If Not SendToServer("DoCmd.RunSavedImportExport "Import-ImportName"", "CommandT_Customer") Then Exit Sub

Any advice?

I know I can do this by linking the source table and just running the SQL code like you do in the video, but this import only occurs once per month, so I don't want to have a linked table.
Richard Rost             
5 months ago
Well you'll have to write code on the server to handle all of that data processing (importing, formatting, etc.) once it receives your command. Pretend like you're running the code AT the server. All you're sending it a message saying "hey... go do THIS and let me know when you're done."
Jeff Bartuch         
5 months ago
Thank you Richard for getting back to me. I guess I'm not following you.

So I'm my case with DoCmd.RunSavedImportExport "Import- ImportName". Let's say I have that in a sub routine in my backend database. What command would I put in my front end to run it on the backend?
Richard Rost             
5 months ago
Whatever you like. Make up your own command. It just has to be something that the back end recognizes to run that routine.
Kevin Yip        
5 months ago
Richard's method works for SQL statements only, not VBA code.  But it can be modified to run VBA code too -- if you can turn VBA code into strings.  This can be done with the Eval() function.  For instance:

     Dim s As String
     s = "MsgBox(""Hello World!"")"
     Eval s

The above code will show the "Hello Word" box as if you ran MsgBox directly.

The limitation is that Eval only accepts expressions.  All functions like MsgBox() and DLookup() are expressions, but DoCmd is not.  But you can put DoCmd inside a custom function to make it an expression:

    Function MyFunction1()
        DoCmd.RunSavedImportExport ...
    End Function

Then you can run Eval with the function's name as a string parameter:    Eval "MyFunction1()"

In Richard's method, the BE can "listen" for strings that are SQL statements.  So you need to modify his code to look for VBA expressions also, and run them with Eval().  I don't have access to Richard's downloads so I can't show you what to modify.  Maybe Richard can in a future video.

I don't know how differently running VBA code instead of SQL statements will affect performance on the BE.  A BE's performance is affected not only by transmitting too much data, but also by being kept too busy.
Richard Rost             
5 months ago
Yeah, basically what I'm saying is just send a command to the server like "RunRicksImport", and then on the server, make a special exception for that. So, if it sees the command you send, it runs a whole separate routine that you've already programmed into the server. This routine can include importing data, running a query on it, doing whatever, and then passing you the data that you need.
Richard Rost             
5 months ago
On the server, you'll find this...

    If Not rs.EOF Then
        ' we have a command
        If rs!CommandText = "LOCK" Then
            Status "Waiting for front-end..."
            Status "Executing " & rs!CommandText
            CurrentDb.Execute rs!CommandText
            Status "Complete"
            rs!CommandCompleted = True
        End If
    End If

See how "LOCK" is a special command. Just make your own commands and put them in the IF block. So you could have something like...

        ElseIf rs!CommandText = "SHUTDOWN" Then
            ' Do shutdown sequence here

The sky's the limit. The server can respond and do whatever you want. It doesn't have to just run SQL commands.
Jeff Bartuch         
5 months ago
Thank you both. I think I get it now. Let me test this out. I'll let you and anyone that reads this forum know how it turned out.

Live long and prosper :)

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Database Server 5.


The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.

Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
My Account
My Courses
Lost Password
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Customer Support
Web Site Tour
Consulting Services
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/15/2024 4:11:13 PM. PLT: 0s