Connect MS Access with Visual Basic 6.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • conics
    New Member
    • Feb 2008
    • 30

    Connect MS Access with Visual Basic 6.0

    how do i make it that when i move the files to another directory but still on one folder i will not have to edit the app path of the ms access?

    when i created a table and connected it to my adodc..
    and when i moved the files to another directory it still searches for the table in the original directory that i indicated beforehand
    thanks
  • VBWheaties
    New Member
    • Feb 2008
    • 145

    #2
    Originally posted by conics
    how do i make it that when i move the files to another directory but still on one folder i will not have to edit the app path of the ms access?

    when i created a table and connected it to my adodc..
    and when i moved the files to another directory it still searches for the table in the original directory that i indicated beforehand
    thanks
    you can always pass in the path to your application or create a textbox in your app for the location or even prompt the user for the location if it cannot be found. many choices available to you.

    Comment

    • conics
      New Member
      • Feb 2008
      • 30

      #3
      Originally posted by VBWheaties
      you can always pass in the path to your application or create a textbox in your app for the location or even prompt the user for the location if it cannot be found. many choices available to you.
      can you tell me how?

      im new at database making

      Comment

      • VBWheaties
        New Member
        • Feb 2008
        • 145

        #4
        Originally posted by conics
        can you tell me how?

        im new at database making
        I suggest using parameters since they are the easiest explain.

        When a parameter is passed in, it gets set to the global "Command" object which is nothing more than a string.

        For example, lets say my application is called MyApp.exe and I need to send in the location of my database. This will be the call to open my program with a commandline parameter:

        C:\Program Files\VBWheatie s\Myapp.exe "C:\Program Files\MyDatabas e\MyData.mdb"

        As you can see MyApp.exe is being called with the commandline parameter of a database path (C:\Program Files\MyDatabas e\MyData.mdb)

        In your code, to get access to this commandline parameter:

        Code:
        Public Sub OnFormLoad()    'on form load or whatever sub you want to make
           Dim DatabasePath As String   
           DataBasePath = Command()  'Command() will give us the parameter 
           'Then continue to load your app as normal. 
        End Sub
        As you can see, Command will have the database path because I passed it in when I launched the exe at the command line (Start>Run)

        More traditionally, you can use shortcuts to pass in commandline parameters.
        You want to make a shortcut for your executable. Let me know if you dont know how to do this.
        In the shortcut, and on the Shortcut tab, you'll see the location of your exe.
        After the quote surrounding the path to your exe (if there is one), put a space, then type in your parameter. Put it in quotes. Save the shortcut.

        When you double-click this shortcut, it will pass the value typed in. This is the commandline parameter that your application will use. Its pretty powerful stuff: you can pass in any string value you choose and your app can use that to do something custom, like change the path to your database file.

        Comment

        Working...