Hi Terence,
If the form is a subform then you can put a
command button on the main form to do the
toggle the view. Otherwise you can toggle the
view by using a DoubleClick Event in one
(or more) of the data fields if you like but
you have to think about indicating to the
user that the option is available.
You could use the Status_Bar_Text and/or the
ControlTip_Text with a message something like,
"DoubleClick to switch the view".
Another possibilty is to add "Click MyField to
change view"
The code is simply,
Private Sub MyField_DblClick(Cancel As Integer)
' ToggleForm/Datasheet View
If Me.CurrentView = 2 Then
DoCmd.RunCommand acCmdFormView
Else
DoCmd.RunCommand acCmdDatasheetView
End If
End Sub
Another point to watch is that the field widths
will vary between views so it is best to use a
field on the lefthand side.
Hope that helps.
Regards, Clive.
--- In MS_Access_Professionals@yahoogroups.com, Crystal <strive4peace2008@...> wrote:
>
> 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
> >
> >
>
Sabtu, 30 Juli 2011
Re: [MS_AccessPros] can you with an event trigger flip a form from form view to datasheet view?
__._,_.___
.
__,_._,___
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar