Sabtu, 30 Juli 2011

RE: [MS_AccessPros] can you with an event trigger flip a form from form view to datasheet view?

 

Hi Terrence,

As John said, there is no way to have a command button that works on a datasheet

note: Datasheet forms do not display the form header or the form footer sections (but you CAN use these sections to do calculations like =Sum([controlname]) and echo those control values to another form even though they don't show)

back to the view issue:
To remedy this and make a command button, make your current form a subform so you can change the view from the mainform.

1. Make a Main Form
Make a new blank form and go into design view. This will become a main form.

2. Make a subform control
Drag the form you already have from the navigation pane -- this makes it a subform on the mainform you are designing. You can also add it the conventional way -- just thought I'd show you a little trick ;)

3. make a command button
Then add a command button flip views on the main form :) Here is the code you need:

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub cmd_FlipView_Datasheet_Form_Click()
'110730 Crystal strive4peace

'use WITH on the subform control for better performance
With Me.f_subform

'set the focus to the subform so DoCmd acts on the right object
.SetFocus

'if not in Form view,
'then make Form View the current view
'otherwise, switch to Datasheet view
'0 Design view
'1 Form view
'2 DataSheet view
If .Form.CurrentView <> 1 Then
DoCmd.RunCommand acCmdSubformFormView
Else
DoCmd.RunCommand acCmdSubformDatasheetView
End If
End With

End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

WHERE
f_subform is the Name property of your subform control. I typically make it the same as the SourceObject

Warm Regards,
Crystal

Access Basics by Crystal (Bill Mosca's site)
http://thatlldoit.com
Free 100-page book that covers essentials in Access

*
(: have an awesome day :)
*

--- On Fri, 7/29/11, John Viescas wrote:

> Terence-
>
> I don't think that's possible, because a form in Datasheet
> view can't show a
> command button to "flip" it back.  The command to
> "flip" to Datasheet would be:
>
>   DoCmd.RunCommand acCmdDataSheetView
>
> John Viescas, author
> Microsoft Office Access 2010 Inside Out
> Microsoft Office Access 2007 Inside Out
> Building Microsoft Access Applications
> Microsoft Office Access 2003 Inside Out
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
>
>
>
> -----Original Message-----
> From: Terence

>
> I want to place a button on a popup form that flips it to
> data sheet view and
> vice versa, but I am not sure what property that would be
> nor what the property
> value would be ?
>
> TY
> Terence
>
>

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar