Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2003
    Posts
    29

    Question Unanswered: Openform - Where clause is ignored

    When opening a form using the Openform statement and Where clause in VB the form opens apparently ignoring the Where Clause.

    Example;
    DoCmd.OpenForm "frmCustomers", , , "Customer_ID = " & 99

    The form will open and display all the records in the Customers table, not just those with Customer_ID = 99.

    I can create a new form exactly like the original form and it will work perfectly. The old form still fails.

    I really dont want to have to recreate all my forms.

    Has anyone else experienced this?

    Any ideas?

    Thanks

  2. #2
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    574
    some ideas:
    - try putting Customer_ID in square brackets
    - what is the name of the Customer_Id in the query?
    - what is the name of the customer_id text box?
    - make sure the Customer_Id record source matches the textbox name

  3. #3
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    Yup, Access will do this to you on a normal basis.

    You may want to try either creating a new database and importing all your objects (takes longer than recreating all your forms). Remember to set any non-standard code references in the new db.

    Or you may want to use the OpenArgs parameter to send the form 99, then let the Open method on your target form use the OpenArgs to create a filter. Remember to set FilterOn = True.
    All code ADO/ADOX unless otherwise specified.
    Mike.

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb Re: Openform - Where clause is ignored

    Originally posted by jnason
    When opening a form using the Openform statement and Where clause in VB the form opens apparently ignoring the Where Clause.

    Example;
    DoCmd.OpenForm "frmCustomers", , , "Customer_ID = " & 99

    The form will open and display all the records in the Customers table, not just those with Customer_ID = 99.

    I can create a new form exactly like the original form and it will work perfectly. The old form still fails.

    I really dont want to have to recreate all my forms.

    Has anyone else experienced this?

    Any ideas?

    Thanks

    Try this
    DoCmd.OpenReport "frmCustomers", acViewPreview, , "[Customer_ID]=forms!yourFormName!yourFiledWhichHasCustomer_ID"

Posting Permissions

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