Michael Holvey
Michael Holvey

Reputation: 3

Closing a single instance of a form in Access

I am working on a database with a search function that might return multiple records of a form (i.e. a range of client IDs). I can freely navigate using the left/right arrows on the bottom of the form - but what if I am interested in closing a single instance of the form once I am done working in it? Ideally I could complete the tasks required for one client, then close that record and have it switch to the next one.

DoCmd.Close acForm, "Form Name"

does not work here, because it closes the entire form.

Please let me know if this makes sense - thanks!

Upvotes: 0

Views: 164

Answers (2)

Teru
Teru

Reputation: 1

Add below code in your form and call yourinstanse.Terminate.

Public Sub Terminate()
    Me.SetFocus
    DoCmd.Close
End Sub

Upvotes: 0

Lynne Davidson
Lynne Davidson

Reputation: 183

You've hinted at the answer already in the question. When you run a query to open a form, if the query returns more than one record it's still only opening one form. The arrows at the bottom take you from one record to the next (or previous) but you are still within one form. You can't close down a single record from other records from the same query. Moving from one record to the next saves the changes, so you really shouldn't need to close a record individually.

Upvotes: 1

Related Questions