Error says "the expression you entered contains invalid syntax" in ACCESS VB code
hi,
I am using MS ACCESS 2003 and using VB code within Access to toggle the screen from datasheet view to form view. code wht i am entering is:
Code:
Public Sub Toggle()
'Toggles the view as the form between datasheet view and form view
'It is going to check the form view
If Me.CurrentView = 1 Then
'form View is Single Form Change to Datasheet
DoCmd.RunCommand (acCmdDatasheetView)
Else
'form View is Datasheet Change to Single Form
DoCmd.RunCommand (acCmdFormView)
End If
End Sub
when entering code i am getting the error:
"the expression you entered contains invalid syntax" , If anyone could advise me then will be appreciated.
Plz accept my ignorance if i miss any thing as i am new to this forums.
Re: Error says "the expression you entered contains invalid syntax" in ACCESS VB code
Surprisingly this code works fine for me! WOuld like to ask you 2 questions:
1. At which line the error is generated? Try using On Error statement get exact error.
2. On which event you are calling this procedure?
Re: Error says "the expression you entered contains invalid syntax" in ACCESS VB code
we find the error where there is Subform including on the form on below line,
DoCmd.RunCommand (acCmdFormView).
and when i remove the subform it works fine.
I am calling on the button of menu bar.