Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / May 2008

Tip: Looking for answers? Try searching our database.

Select Case - SQL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
auujxa2 - 26 May 2008 20:15 GMT
We have different networks for different divisions, and since I can't predict
the division, I'm using a select case method.  I only entered 1 case.  The
case is the path the current user is in.  

The query runs fine.  But it's updating the current database, not the "Run
Tracker" database. I need to shift the focus and define the objACC database
for the SQL code.  I tried "With", that didn't work.

Please help.  Thank you in advance.

Dim strSQL As String
Dim CurrentUser As String
Dim strProjectPath As String
Dim objACC As New Access.Application

strProjectPath = Application.CurrentProject.Path

CurrentUser = Environ("UserName")

DoCmd.SetWarnings False

Select Case strProjectPath

   Case ("\\s914pub\Vendor Matrix - BSS")

               Set objACC = GetObject("\\s914pub\Run Tracker\Run Tracker.
mdb")

               strSQL = "INSERT INTO MasterTbl ( When, Who, What)" & _
                        " SELECT Now()" & "," & " """ & CurrentUser & ""","
& " " & "'A1'" & " AS Str"

               DoCmd.RunSQL strSQL

               strSQL = " UPDATE [MasterTbl] SET [Path] = Application.
CurrentProject.Path" & _
                        " WHERE [Path] is Null"
       
               DoCmd.RunSQL strSQL

               objACC.Quit

End Select
Michel Walsh - 27 May 2008 14:31 GMT
The Connect property gives the intended mdb:

   ? CurrentDb.TableDefs("YourLinkedTableNameHere").Connect
   \\s914pub\Run Tracker\Run Tracker.mdb

If you want to change it, specify the Connect property with the new
location, and THEN, refreshLink:

   CurrentDb.TableDefs("YourLinkedTableNameHere").RefreshLink

You can store the various paths in a local table, two fields:

shortName,                                            fullPath        '
fields name
"\\s914pub\Vendor Matrix - BSS"     " \\s914pub\Run Tracker\Run Tracker.mdb"
           ... data sample

and make a DLookup on the short name, to get the full path (rather than
using a hard coded Select-Case). You can so add/modify the related tables
without touching the code itself, much much more secure, safe, or
maintanable.

Vanderghast, Access MVP

> We have different networks for different divisions, and since I can't
> predict
[quoted text clipped - 42 lines]
>
> End Select
auujxa2 - 27 May 2008 15:03 GMT
I figured it out.

I just simply put objACC in front of the docmd.runSQL

thank you for taking the time to help me

>The Connect property gives the intended mdb:
>
[quoted text clipped - 25 lines]
>>
>> End Select

Signature

Laser

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.