dbTalk Databases Forums  

Mainform/Subform Change Subform View

comp.database.ms-access comp.database.ms-access


Discuss Mainform/Subform Change Subform View in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
wdgriggs
 
Posts: n/a

Default Mainform/Subform Change Subform View - 07-07-2004 , 09:21 AM






I'm sure it's simple but....
Have a mainform / subform subform defaults to form view. Want a
toggle button on mainform to toggle subform from formview to datasheet
view and back. Looked everywhere for help.
Thanks.

Reply With Quote
  #2  
Old   
wdgriggs
 
Posts: n/a

Default Re: Mainform/Subform Change Subform View - 07-09-2004 , 10:26 AM






wdgriggs (AT) ftc-i (DOT) net (wdgriggs) wrote in message news:<3ccf9c62.0407070621.672afad3 (AT) posting (DOT) google.com>...
Quote:
I'm sure it's simple but....
Have a mainform / subform subform defaults to form view. Want a
toggle button on mainform to toggle subform from formview to datasheet
view and back. Looked everywhere for help.
Thanks.
Answered my own question:
This example uses a button called cmdDatasheet and a subform control on the
Main Form called subTestForm. It changes the caption of the button to
reflect the change that will occur when clicked.

'***************** Code Start *******************
'This code was originally written by Terry Wickenden.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.

Private Sub cmdDatasheet_Click()
On Error GoTo ErrCmdDatasheet

Me.subTestForm.SetFocus
DoCmd.RunCommand acCmdSubformDatasheet
If Me.cmdDatasheet.Caption = "Datasheet View" Then
Me.cmdDatasheet.Caption = "Form View"
Else
Me.cmdDatasheet.Caption = "Datasheet View"
End If
Exit Sub

ErrCmdDatasheet:
Select Case Err
Case 2046
'Datasheet view not available
MsgBox "This command not available at this time"
Exit Sub
Case Else
MsgBox Err.Number & vbCrLf & Err.Description
Exit Sub
End Select

End Sub


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.