Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2005

    Unanswered: Filtering a Form

    I need some help with adding a filter to a form. I have a form which is based on a query, I want to be able to either add data, edit data or view data.

    Now I'll be more specific....

    When I click a button on the main menu form a new form pops up with 3 options, to add a record, update/delete a record or view all records.

    Add record - I want to open the form to a new record and enter info

    Update/Delete - I want to see the entire database in read-only and then give them the option to click an update button and open the form at that record.

    View all - open up the form in read only

    I have a form created and I've had no problem with opening the form at a new record or viewing it as read only. The problem is when I want to filter for just that current record. I have used mostly macros, it's been a really long time since I used code (but I probably could bluff my way through it).
    I have no idea how to set the filter, I tried looking back at a database I did a few months ago but I have no idea how I did it!

    Any suggestions!

  2. #2
    Join Date
    Jan 2005
    what i would do in this situation is just set the recordsource for the update form to a query which used the selected record as a parameter. the code would look something like this

    your update button click event:
    dim CurrRecord as Integer
    dim strSQL as string

    CurrRecord = Me!Id
    strSQL = "SELECT * FROM table WHERE id = " & CurrRecord & ";"
    DoCmd.OpenForm "UpdateForm"
    Forms!UpdateForm.RecordSource strSQL

Posting Permissions

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