Locate existing record-update it on the form

  • Thread starter Thread starter ADB_Seeker
  • Start date Start date
A

ADB_Seeker

I placed a command button on a form and want to use it to search for an
existing record and then populate the form with that record so I can
update/add to it.
The form's record source is a table (tblRFPTracking).
I'm having a mental block on how to accomplish this and appreciate any help.
Linda
 
Here's one approach...

Add a combobox (unbound) to the form (I stick mine in the header).

Have that combobox list the records available for editing. I usually only
include the bare minimum necessary to distinguish one record from another.
Use a query to "feed" this combobox.

Use another query that returns all of the records that might go into the
form, and all of their fields that you'd want to edit.

Bind the form to that (second) query.

Now modify that (second) query to point to the combobox on the form for the
ID of the record you wish to edit. Note that this means you need to have
the first column of the (first) combobox query include the ID. You can set
the width of that first column to 0 so you don't have to see it.

One more thing ... in design view for the form, highlight the combobox and
add an Event Procedure to the AfterUpdate event. It needs:

Me.Requery

Here's the gist of how this works:

* You open the form, the combobox is empty, so the form/query returns
that record (i.e., none)
* You pick a record from the combobox and <tab>/<enter> out ...
* The form reruns the query, which now finds a value in the combobox
* The form loads the record with the ID of the record selected in the
combobox.

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
Back
Top