Don't set focus if no records returned

StarvinMarvin

still quite the noob
Local time
Today, 17:04
Joined
Mar 8, 2010
Messages
171
Have an instance where the operator enters an employee # and a subform query off the employee number refreshes to show all records for that employee number. I have delete button in the details section for each record if they need to delete a record.

Initial problem was the error, delete function not available at this time when attempting to just click the delete button. I had to select a field in the subform first in order to allow the delete function to work.

So rather than have the operator have to drop off the cursor in one of the returned text fields to delete a record, I set focus to a field in the detail section after main form submit. This works fine, until the subform doesn't return a record, then I can't set focus on no record and get an error because I can't set focus to an object that didn't exist.

Is there another way around not being able to delete a record in a subform using a delete button inside the subform detail area without having to focus on an item in the subform first?
 
I'll assume that you have a database set up where the table that holds the values for this subform has a unique ID.
If that Unique ID is on the subform (even hidden) then you can create a delete query.
Set the delete query to delete a record for your table where the criteria is: [SubformName]![Control where uniqueID is storedname]

This will mean when the delete query runs, it deletes record number X where X is the ID on the subform. Then all your button has to do is run that query.
 
so I can throw that in the on_click and put the button in the detail section on the subform?
 
yep, the button can go wherever you want. your query should specifically reference the subform by name so it doesn't matter if the button is on the parent or the subform.
 

Users who are viewing this thread

Back
Top Bottom