Record Selectors

mtagliaferri

Registered User.
Local time
Today, 10:04
Joined
Jul 16, 2006
Messages
550
When a form property has "Record Selectors" set to yes is there a way to use this to click/double click to create an event as a detailed form?
 

Attachments

  • P1.jpg
    P1.jpg
    16.8 KB · Views: 192
No you can't as the record selectors aren't visible in Design view
However, you can add similar code to any of the fields shown in your form
 
When a form property has "Record Selectors" set to yes is there a way to use this to click/double click to create an event as a detailed form?
If the form is displayed as "Form View" then it can have an event procedure run when it is Clicked/DoubleClicked but I don't understand what you meant by:
....create an event as a detailed form
 
Hi Bob,

Yes of course you can do form event code
... but not code on the record selector itself AFAIK
...or am I being stupid (again)?
 
Hi Colin
... but not code on the record selector itself AFAIK
Not sure what you mean by this.
Just wanted to make the OP aware that code runs when the record selector is Clicked/Double Clicked
 
The OP circled the record selector in the image attached to the first post.
So I assumed he/she wanted to know if a RecordSelector_Click event existed.
 
The Record Selector isn't a control but it is part of the form. Consequently the Form_Click and Form_DoubleClick Events will apply to it. These are fired everywhere on the form where there are no controls.

Of course every other vacant part of the form would also fire these events, which would not normally be expected, particularly the click event.

Try this. Place an unbound textbox over the entire form. Set its properties as follows.

Locked = Yes
Enabled = No
Backstyle = Transparent (to allow the form background to show)
Borderstyle = Transparent

Send it to the back (Position section of Context Menu)

Now only the selector will respond to the double click.
 
I think I will revert to my Plan A which is double click on the [TimelineDate], I would like to open the form NOT in edit mode and I have removed the acEdit from the below code, as I will have an Edit cmd on the opened form it self, but by removing the acEdit I get a An expression in argument 5 has an invalid value any hints?

Code:
Private Sub TimelineDate_DblClick(Cancel As Integer)
On Error GoTo TimelineDate_DblClick_Err

    DoCmd.OpenForm "frmUpdatesTimeline", acNormal, "", "[IDUpdatesTimeline]=" & IDUpdatesTimeline, acEdit, acDialog
    
TimelineDate_DblClick_Exit:
    Exit Sub

TimelineDate_DblClick_Err:
    MsgBox Error$
    Resume TimelineDate_DblClick_Exit

End Sub
 
as in:
Code:
IDUpdatesTimeline, , acDialog
I have tried and like this it will open the form displaying no records!
 
There were 2 errors in this line - marked in RED:

Code:
DoCmd.OpenForm "frmUpdatesTimeline", acNormal, [COLOR="Red"]""[/COLOR], "[IDUpdatesTimeline]=" & IDUpdatesTimeline, [COLOR="red"]acEdit[/COLOR], acDialog

1. If an argument is blank, don't enter ""
2. It should have been acFormEdit NOT acEdit

However if you want the form to be read only, then the correct code is:

Code:
DoCmd.OpenForm "frmUpdatesTimeline", acNormal, , "[IDUpdatesTimeline]=" & IDUpdatesTimeline, acFormReadOnly, acDialog
 
Thanks Colin,
that solved the issue, but with one thing solved it triggers something else...
I have to cmd uttons on the form opened in Read only, one is a save comd and one an edit, if I edit the form and the save it all works fine, but if I don't make any changes and press the save I get an error "The command or action 'SaveRecord' is not available now".
Code:
On Error GoTo CmdSave_Click_Err

    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.Close acForm, "frmUpdatesTimeline"


CmdSave_Click_Exit:
    Exit Sub

CmdSave_Click_Err:
    MsgBox Error$
    Resume CmdSave_Click_Exit
I would like to keep the form neat and have only one cmd button that does the save and close function too so thatI don't confuse the user or risk changes to the form that is then been closed and not saved, hope this makes sense!
 
Thanks Colin,
that solved the issue, but with one thing solved it triggers something else...
I have two cmd buttons on the form opened in Read only, one is a save comd and one an edit, if I edit the form and the save it all works fine, but if I don't make any changes and press the save I get an error "The command or action 'SaveRecord' is not available now".

That's because your form is in read only mode (locked) so it can't save anything.
So you need to detect that situation with modified code.

However if your form controls are bound to table fields, any changes made in edit mode will be saved automatically.
If that is the case with your form, you should omit the code used to save the record

Whereas, if the fields are unbound, you may need to save each change individually

I would like to keep the form neat and have only one cmd button that does the save and close function too so thatI don't confuse the user or risk changes to the form that is then been closed and not saved, hope this makes sense!

I agree - fewer buttons is better.
I suggest you put the combined code in the cmdClose_Click procedure

If you need to save the changes (see above comments), either of the following should do the job (unless you need to save each field individually.
Choose whichever you prefer.

Code:
Private Sub cmdClose_Click()

On Error GoTo CmdClose_Click_Err

'save any changes if in edit mode
    If Me.Dirty Then Me.Dirty=False

    DoCmd.Close acForm, Me.Name

CmdClose_Click_Exit:
    Exit Sub

CmdClose_Click_Err:
    MsgBox "Error " & err.Number & " : " & Err.Description
    Resume CmdClose_Click_Exit

End Sub

OR

Code:
Private Sub cmdClose_Click()

On Error GoTo CmdClose_Click_Err

'save any changes if in edit mode
    If Me.Locked=False Then DoCmd.Save

    DoCmd.Close acForm, Me.Name

CmdClose_Click_Exit:
    Exit Sub

CmdClose_Click_Err:
    MsgBox "Error " & err.Number & " : " & Err.Description
    Resume CmdClose_Click_Exit

End Sub

HTH
 
Last edited:

Users who are viewing this thread

Back
Top Bottom