Programmatic toggle form between FormView and Datasheet view 
Author Message
 Programmatic toggle form between FormView and Datasheet view

Hello group,

This one is having me scratch my head!

I wish to program a FunctionKey (vbKeyF9) such that when the user hits it,
the form switches view, in a toggle fashion, from form view to datasheet
view and back.

I trap the user's hitting the Fkey in the form_KeyDown event.  From the
event procedure, I call a 'ToggleView' procedure.  This procedure in turn
checks the current view (Me.CurrentView), and accordingly issues either
1- DoCmd.RunCommand acCmdFormView  or
2-DoCmd.RunCommand acCmdDatasheetView

This generates runtime error 3270 - Property not found.  I have no clue as
to the reason.

Additional info:
I can invoke the ToggleView elsewhere, ex. from the debugging window - and
that works fine.  So it appears I can't switch views from within an event
handler in the form.

Any suggestions?

Thanx!

Ren
Montreal



Fri, 19 Aug 2005 03:23:58 GMT  
 Programmatic toggle form between FormView and Datasheet view
Rene, it does look like you are not permitted to switch views in the KeyDown
event of the form, though I'm seeing a different error message (2174):
    You can't switch to a different view at this time.

As you say, the same code works elsewhere, e.g. in the Click of a command
button. Clearly that's no use for switching back out of datasheet view
again. Could you work around the issue with a toolbar button?

--
Allen Browne - Microsoft MVP (Most Valuable Professional)
Allen Browne's Database And Training - Perth, Western Australia.
Tips for MS Access users - http://allenbrowne.com/tips.html
Reply to the newsgroup. (Email address has spurious "_SpamTrap")


Quote:
> Hello group,

> This one is having me scratch my head!

> I wish to program a FunctionKey (vbKeyF9) such that when the user hits it,
> the form switches view, in a toggle fashion, from form view to datasheet
> view and back.

> I trap the user's hitting the Fkey in the form_KeyDown event.  From the
> event procedure, I call a 'ToggleView' procedure.  This procedure in turn
> checks the current view (Me.CurrentView), and accordingly issues either
> 1- DoCmd.RunCommand acCmdFormView  or
> 2-DoCmd.RunCommand acCmdDatasheetView

> This generates runtime error 3270 - Property not found.  I have no clue as
> to the reason.

> Additional info:
> I can invoke the ToggleView elsewhere, ex. from the debugging window - and
> that works fine.  So it appears I can't switch views from within an event
> handler in the form.



Fri, 19 Aug 2005 10:03:36 GMT  
 Programmatic toggle form between FormView and Datasheet view
Hello Alen,

Thank you for your reply.

On your suggestion of using a toolbar button, that is how I went about it in
previous versions of my program.  I (for no reason I can intelligently
provide) dislike toolbars somewhat.  This is why I was hoping to achieve
similar functionality using an Fkey.

Ah well, I'll let that one simmer for a while - time may yield a usefull
clue!

Ren


Quote:
> Hello group,

> This one is having me scratch my head!

> I wish to program a FunctionKey (vbKeyF9) such that when the user hits it,
> the form switches view, in a toggle fashion, from form view to datasheet
> view and back.

> I trap the user's hitting the Fkey in the form_KeyDown event.  From the
> event procedure, I call a 'ToggleView' procedure.  This procedure in turn
> checks the current view (Me.CurrentView), and accordingly issues either
> 1- DoCmd.RunCommand acCmdFormView  or
> 2-DoCmd.RunCommand acCmdDatasheetView

> This generates runtime error 3270 - Property not found.  I have no clue as
> to the reason.

> Additional info:
> I can invoke the ToggleView elsewhere, ex. from the debugging window - and
> that works fine.  So it appears I can't switch views from within an event
> handler in the form.

> Any suggestions?

> Thanx!

> Ren
> Montreal



Fri, 19 Aug 2005 20:38:45 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Toggling between Form view & Datasheet view

2. Toggle Subform from Form-view to Datasheet-view Programatically

3. Toggle Subform between Form-view and Datasheet-view Programmatically

4. Toggle Between Form and Datasheet Views

5. Toggle between datasheet and form view in subform

6. Datasheet View subForm and Form View subForm on same Master Form

7. linking Main form in single form view to subform in datasheet view

8. Send a Form with only one record in a Form view not a datasheet view

9. How do I mail a form in Form View not in datasheet view

10. AutoKeys - Toggle between FormView and DatasheetView


 
Powered by phpBB® Forum Software © phpBB Group