Datasheet to Form View

  • Thread starter Thread starter Normand
  • Start date Start date
N

Normand

How can I select a record in a Datasheet View and on
doubleclick event open the FormView of that same record.
 
How can I select a record in a Datasheet View and on
doubleclick event open the FormView of that same record.

If the form is a main form (in other words, not a subform) then you can use
this:

'******EXAMPLE START
Private Sub Form_DblClick(Cancel As Integer)

Const conFormView = 1
Const conDataSheet = 2

If Me.CurrentView = conFormView Then
DoCmd.RunCommand acCmdDatasheetView
ElseIf Me.CurrentView = conDataSheet Then
DoCmd.RunCommand acCmdFormView
End If

End Sub
'******EXAMPLE END

If the form is a subform, then you can use this:

'******EXAMPLE START
Private Sub Form_DblClick(Cancel As Integer)

DoCmd.RunCommand acCmdSubformDatasheet

End Sub
'******EXAMPLE END
 
Thank you Bruce, I will try it.
-----Original Message-----

If the form is a main form (in other words, not a subform) then you can use
this:

'******EXAMPLE START
Private Sub Form_DblClick(Cancel As Integer)

Const conFormView = 1
Const conDataSheet = 2

If Me.CurrentView = conFormView Then
DoCmd.RunCommand acCmdDatasheetView
ElseIf Me.CurrentView = conDataSheet Then
DoCmd.RunCommand acCmdFormView
End If

End Sub
'******EXAMPLE END

If the form is a subform, then you can use this:

'******EXAMPLE START
Private Sub Form_DblClick(Cancel As Integer)

DoCmd.RunCommand acCmdSubformDatasheet

End Sub
'******EXAMPLE END

--
Bruce M. Thompson
(e-mail address removed) (See the Access FAQ at http://www.mvps.org/access)
within the newsgroups so that all might benefit.<<


.
 
Thanks Bruce

I was trying to do this myself now is it possible to put a command button on
the form to go back to datasheet view?

Thanks Cliff
 
Back
Top