What Event Occurs When Record Selected on Subform?

cblaine99

Registered User.
Local time
Yesterday, 22:56
Joined
Mar 10, 2016
Messages
29
I am helping a friend with his Access 2007 database. I have some basic competency
with Access 2007 but am having a problem with a form. This form contains a subform
which has data that came from a query. I have attached an image showing the form.

I would like to do two things:

- Allow user to click in the record selector column, but not allow them to delete the record by pressing the DEL key
- Notice the event that occurs when user selects a record. Then I will enable the "Edit" command button at the bottom.
Otherwise the button would be disabled.

I would like to know which event occurs when a record is selected. Then I can execute VBA code to enable the button.

Thank you.
 

Attachments

  • ContactForm.gif
    ContactForm.gif
    33.1 KB · Views: 148
The on_current event is probably what you are looking for.
However, I can't see the point of disabling the button as you will always be on a record?

Set the form to not allow deletions.

I'm not aware of any event that captures the use of the record selectors, but happy to be educated?
 
hi cblaine,

there is no event I know of to detect when a record is specifically selected, as opposed to just being on the record. As Minty said, this is the Current event and
you can set Allow Deletions to No for the form

PropertySheet_Form_Data.png


You can also suppress the display of the Record Selectors

PropertySheet_Form_Format_toRecordSelectors.png


and it might be better to have your Edit button always be enabled, instead of the user having to select the record to get it to work. Perhaps if the user is on a new record, you could disable it. You can check the Current event for Me.NewRecord -- then enable it again on the form AfterUpdate event
 
Last edited:
the Form click event also fires when you click on the record selector.
 
The on_current event is probably what you are looking for.
However, I can't see the point of disabling the button as you will always be on a record?

Set the form to not allow deletions.

I'm not aware of any event that captures the use of the record selectors, but happy to be educated?
Thanks for the advice about keeping the button enabled.
 
hi cblaine,

there is no event I know of to detect when a record is specifically selected, as opposed to just being on the record. As Minty said, this is the Current event and
you can set Allow Deletions to No for the form

View attachment 81233

You can also suppress the display of the Record Selectors

View attachment 81234

and it might be better to have your Edit button always be enabled, instead of the user having to select the record to get it to work. Perhaps if the user is on a new record, you could disable it. You can check the Current event for Me.NewRecord -- then enable it again on the form AfterUpdate event
Thank you. Excellent advice.
 
surely it does, i just tested it.
its the subform's click event.
 
surely it does, i just tested it.
its the subform's click event.
t looked at the properties for the subform and the only two events shown are "On Enter" and "On Exit".
I don't see "On Click".
 
t looked at the properties for the subform and the only two events shown are "On Enter" and "On Exit".
I don't see "On Click".

I suspect You're Falling Into the Trap provided by Microsoft. You are actually looking at the subform/subreport control which surrounds your subform.
 
t looked at the properties for the subform and the only two events shown are "On Enter" and "On Exit".
I don't see "On Click".
You're looking at the properties of the subform control. click the top left square of the subform (where the horizontal and vertical rulers meet) to see the properties of the subform.
 
You're looking at the properties of the subform control. click the top left square of the subform (where the horizontal and vertical rulers meet) to see the properties of the subform.
Thank you.
 
cblaine, realize that even if you write code for the form click event, you won't be able to tell if the click was to select the record or it was just a random click somewhere else ...

The subform control is just a container for the subform. Its properties are things to describe how big it is, where it is, and what form is inside it. It is what gets selected the first time you click on the subform. That is why you only saw Enter and Exit events.

The second click gets you inside the container, to the form it contains. There you will see the properties for the form itself
 

Users who are viewing this thread

Back
Top Bottom