change subform from Form View to Datasheet view

smercer

Registered User.
Local time
Tomorrow, 06:28
Joined
Jun 14, 2004
Messages
442
Hi all

how do you change a subform in form view into datasheet view using coding (for on_click on a option button)?

also when the user clicks on the origanal option button, I would like it to be able to get back to the origanal form view.

thanks all for helping.
 
i don't know how to do this in code, why not instead create the subform twice, once in datview once in form view. then with the control button, use subform1.visible = True
subform2.visible = False
etc

make one of the subforms invisible as default


any use?
 
yeah I have done this before, I was wondering if there is a less confusing way. gets confusing with too many forms all over the place. however if there is no alternative then I will have to do it that way.

thanks for replying
 
just found a thread by hedgeKam saying the following, sorry i couldn't see thread number

Code:
Private Sub cmdChangeView_Click()
Me.YourSubformControlName.SetFocus
DoCmd.RunCommand acCmdSubformDatasheet
End Sub

hope this helps
 
Thanks

I'll try it out in the morning as it is getting late here.
 
That code works perfectly :)

Abit more:
Code:
Private Sub button_Click()
    If button.Caption = "Datasheet view" Then
        Me.subformname.SetFocus
        DoCmd.RunCommand acCmdSubformDatasheet
        button.Caption = "Form view"
    Else
        Me.subformname.SetFocus
        DoCmd.RunCommand acCmdSubformFormView
        button.Caption = "Datasheet view"
    End If
End Sub
 
Thanks HedgeKAM and IanMilly,

I got it working (after taking out what I needed)

I really appretiate your work and effort.
 

Users who are viewing this thread

Back
Top Bottom