switching to datasheetview

303factory

Registered User.
Local time
Today, 13:05
Joined
Oct 10, 2008
Messages
136
I have a bit of a problem with switching between form view and datasheet view now my main form has two subforms

I used to use the following code

Code:
Private Sub btnSwitchView_Click()

intview = Me.DisplayPanel.Form.CurrentView

' change view
If intview = 1 Then
    DoCmd.RunCommand acCmdSubformDatasheetView
End If
If intview = 2 Then
    DoCmd.RunCommand acCmdSubformFormView
End If

End Sub

This worked fine for ages but now I've got two subforms, I now get the error
'The command or action 'SubformDataSheetView' isnt available now.

I tried putting moving the button onto the header of the subform I want changed. The code now works, but as soon as you switch to datasheet view the header and the button dissapear so you cant switch back!

Anyone able to help with this? been on my todo list for ages and im really stuck

303
 
This link should help you get the correct syntax for referring to subforms, their control and properties.
 
This link should help you get the correct syntax for referring to subforms, their control and properties.

According to that I'm already using the correct syntax, and the syntax used to work. All I've done is put an extra subform on the main form (which i want my code to ignore), there's no subforms within subforms or anything like that.

edit: If I use
Code:
Me.DisplayPanel.Form.CurrentView = 2
as a command it says 'This property is read-only and can't be set', hence me using the
Code:
DoCmd.RunCommand acCmdSubformDatasheetView
command, which no longer works.
 

Users who are viewing this thread

Back
Top Bottom