Results 1 to 2 of 2

Thread: Rewrite access query from VB

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Antrim
    Posts
    80

    Unhappy

    Hi

    I'm writing a visual basic program to automate a series of remote site dial in status checks.

    After each site is checked I am writing back the site name and status to a table in an access database.

    I want to enable users to print an access report depending on the date they put into a text box on one of my VB forms.

    The report takes it's data from a query in the database.

    The select query currently goes like this:

    SELECT * FROM tblMain WHERE Date =

    What do I need to put on the end in order to make the query dependant on the string from my VB project (strCurrentDate)

    Any suggestions would be much appreciated.

    Best Regards.

    Rob Brown

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Posts
    253

    Lightbulb

    Follow these steps:
    1. Set the report's data source to the table "tblMain".
    2. Add a reference to the Microsoft Access Object Library.
    3. Use this code snippet to open the report:

    Dim AccessApp As Access.Application

    Set AccessApp=New Access.Application
    AccessApp.OpenCurrentDb YourDatabasePath
    AccessApp.DoCmd.OpenReport YourReportName,,,"[Date]=#" & _ Form1.txtDate.Text & "#"

    Explanation: Instead of changing the Access query's SQL statement, you can launch Access from VB and display the report with a filter.

    Hope this will help you!

Posting Permissions

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



Click Here to Expand Forum to Full Width