+ Reply to Thread
Results 1 to 3 of 3

Database Query Macro- password prompt

  1. #1
    Registered User
    Join Date
    02-17-2009
    Location
    Edison, NJ
    MS-Off Ver
    Excel 2003
    Posts
    5

    Database Query Macro- password prompt

    I have created an Excel sheet that retrieves data from a ODBC source. I have created a macro using macro recorder to refresh the data by re-connecting to the database. However, the connection requires a password prompt and when the macro is run, you are still required to enter the password.

    Is there anyway to make the macro so that the password is automatically entered and the user will just have to press a button to fully run the query update? Thanks for any help on this.
    Last edited by emccormi2003; 02-26-2009 at 04:55 PM.

  2. #2
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264

    Re: Database Query Macro- password prompt

    Hi

    If you right-click in the data table (ie the returned results to the sheet) you should see an option for DataRange Properties (or something like that - I don't have Excel in fron of me at the moment). If you click on this, you should have a "Save password" option in there. You can also set the database to refresh on opening the workbook or every few minutes.

    I guess I don't really undersatnd why you need a macro to refresh the data - one thing about the macro recorder and external queries is that it creates a new query table each time (based on the QueryTables.Add method. This is unnecessary, as if you are simply looking ot refresh the data, you just need to pass the Refresh method of the QueryTable object:

    Please Login or Register  to view this content.
    Richard
    Richard Schollar
    Microsoft MVP - Excel

  3. #3
    Registered User
    Join Date
    02-17-2009
    Location
    Edison, NJ
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Database Query Macro- password prompt

    Thanks, that did exactly what i needed. In response to your question, I don't want the sheet updated each time the workbook is opened. I have made an application that will be used by several users and only the owner will be able to update the data. They will be going in about once a month to update prices based on our database. So basically, I have just made a button on a different sheet to update the list which subsequently changes the prices on another sheet so the owner will not have to go through and do all of this. Hope this answered that question. Thanks for your help though!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1