Results 1 to 3 of 3

Thread: Help!

  1. #1
    Join Date
    Apr 2004

    Unanswered: Help!

    I'm trying to open a query from Microsoft Access that I have created and then sort the data by date. Can someone help me? It is saying object "CustomerService" is not open. "CustomerService" is the name of my query. Here is what I have.

    Dim strConPath As String

    DateCheck = GetDate.DateBox.Text
    strConPath = "Z:\CSGG2_be.mdb"

    ' Create new instance of Microsoft Access.
    Set appAccess = CreateObject("Access.Application")
    ' Open database in Microsoft Access window.
    appAccess.OpenCurrentDatabase strConPath, True
    ' Open Orders form.
    appAccess.DoCmd.SelectObject acQuery, "CustomerService"
    appAccess.DoCmd.OpenQuery "CustomerService", acReadOnly
    DoCmd.GoToRecord , acDataQuery, "CustomerService", acFirst
    End Sub

    Also, is GoToRecord an ok way to go through the records to filter out by date? or is there a better way?

  2. #2
    Join Date
    Feb 2004
    This line is using a default paramenter when the last argument is omitted;
    DoCmd.SelectObject acQuery, "CustomerService"[, false]

    False means that the object is allready open and is the default if the argument is omitted

    So to select an object that is NOT open
    DoCmd.SelectObject acQuery, "CustomerService", True

  3. #3
    Join Date
    Apr 2004
    Ok, I got another problem. When I take appAccess off form the beginning.

    DoCmd.SelectObject acQuery, "CustomerService", True

    it says Object Required.

    When I have it on:

    appAccess.DoCmd.SelectObject acQuery, "CustomerService", True

    it says, that Microsoft Access can find the table you referenced in the Object name argument...but I have checked several time and that is a vlid Query.

    Any ideas?

Posting Permissions

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