Datasheet to Form View

N

Normand

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

Bruce M. Thompson

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
 
N

normand

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.<<


.
 
C

Cliff Waters

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top