Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2001
    Posts
    45

    Question Unanswered: VBA adjust of Form.Filter and Form.OrderBy causes strange requeries

    So I am using some module functions to adjust the recordsource, the filter and the orderby of a form according some user settings (being saved in some configuration tables):

    DoCmd.OpenForm "frmEditClient", acNormal, , , , acWindowNormal
    updateClientRecordset
    applyClientFilter
    updateClientRecordsetOrder

    1. Opening the form
    2. Setting the Form.Recordsource
    3. Applying the Filter (+ setting FilterOn=True)
    4. Applying the Order (+ setting OrderByOn=True)

    I am using a procedure like this for different data departments (Clients, Invoices, etc.). However in ONE of them something strange happens:

    AFTER THE RECORDSET ORDER IS SET (4.), THE FORMER ADJUSTED FILTER IS TURNED OFF AGAIN BY ACCESS. In other words, the filter is removed automatically ("") when I set OrderBy values. Again, this does not happen in the other departments (containing basically the same code). --- Some special access situation again?

  2. #2
    Join Date
    Nov 2001
    Posts
    45
    Well indead it was the query!

    And the solution:

    Object References la "[application].[CurrentUser]" that work perfectly inside a regular QBD Query have to be rebuilt in VBA:

    ("...WHERE (((tblUserInvoicesSelection.strUserID)=[application].[currentuser]));", dbOpenDynaset)

    turns into:

    ("...WHERE (((tblUserInvoicesSelection.strUserID)='" & Application.CurrentUser & "'));", dbOpenDynaset)

    :-)

Posting Permissions

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