Results 1 to 3 of 3

Thread: Filtering forms

  1. #1
    Join Date
    Mar 2004
    Posts
    1

    Unanswered: Filtering forms

    Hi! This novice databaser has a question. I have the follwing code:

    Private Sub cmdButton1_Click()
    On Error GoTo Err_cmdButton1_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = " My Form "

    'I'm first opening the form in datasheet view using acFormDS

    DoCmd.OpenForm stDocName, acFormDS, , "Name of Field in Main Table = 'Criteria I want to filter on'"

    Exit_cmdButton1_Click:
    Exit Sub

    Err_cmdButton1_Click:
    MsgBox Err.Description
    Resume Exit_cmdButton1_Click

    End Sub


    Basically, on clicking this button cmdButton1, I want to open "My Form" in Datasheet view, ONLY with the values that meet the criteria I set in the Where clause.

    Ismy code right? I keep getting a Type Mismatch Error....

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Here is an Example when using a filter to open a report

    DoCmd.OpenReport " ReportName", acViewPreview, , "[fieldName]=forms!yourFormName!txtFieldName"

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    I think you can do the same for a Form

Posting Permissions

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