A button alternative to double-clicking a subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a subform viewed in datasheet display where a user can conveniently
view the details of that record in single-form view (pop-up) by
double-clicking
the subform.

However, some users prefer a button on the main form that they can
single click after selecting a record in the subform

The tricky part is getting the main form to recognize:
1) if anything has been selected in the subform
2) what has been selected

how can I get the following code to recognize the above 2 conditions?
DoCmd.OpenForm "frmDetails", acNormal, , "ID = " &
Form_sbfrm_Tasks_Interface.ID

Also tricky, is that if a routine is written in the 'Click' Event it will
interfere with the 'double-click' event.

I know I saw an example of this somewhere, but I can't seem to find it.
 
Hi Jonefer

I assume you already have some code to handle the DblClick event(s) in the
subform.

I suggest you make it a Public function in the subform's module:

Public Function OpenDetailsForm()
DoCmd.OpenForm "frmDetails", acNormal, , "ID=" & ID, _
WindowMode:=acDialog
End Function

Then, for the OnDblClick property of the form/controls, call the function:
=OpenDetailsForm()

And then in the Click event procedure for the button on your main form, call
the subform's function:

Private Sub CmdShowDetails_Click()
Call Me!sbfrm_Tasks_Interface.OpenDetailsForm()
End Sub
 
Thanks, the clean up was nice too.

Graham Mandeno said:
Hi Jonefer

I assume you already have some code to handle the DblClick event(s) in the
subform.

I suggest you make it a Public function in the subform's module:

Public Function OpenDetailsForm()
DoCmd.OpenForm "frmDetails", acNormal, , "ID=" & ID, _
WindowMode:=acDialog
End Function

Then, for the OnDblClick property of the form/controls, call the function:
=OpenDetailsForm()

And then in the Click event procedure for the button on your main form, call
the subform's function:

Private Sub CmdShowDetails_Click()
Call Me!sbfrm_Tasks_Interface.OpenDetailsForm()
End Sub
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


jonefer said:
I have a subform viewed in datasheet display where a user can conveniently
view the details of that record in single-form view (pop-up) by
double-clicking
the subform.

However, some users prefer a button on the main form that they can
single click after selecting a record in the subform

The tricky part is getting the main form to recognize:
1) if anything has been selected in the subform
2) what has been selected

how can I get the following code to recognize the above 2 conditions?
DoCmd.OpenForm "frmDetails", acNormal, , "ID = " &
Form_sbfrm_Tasks_Interface.ID

Also tricky, is that if a routine is written in the 'Click' Event it will
interfere with the 'double-click' event.

I know I saw an example of this somewhere, but I can't seem to find it.
 
Back
Top