Methods of some objects, example the DoCmd object, seem to be syntactically incorrect if round brackets are used, eg
DoCmd.GoToRecord , , acNewRec is correct, and
DoCmd.GoToRecord (, , acNewRec) is not, whereas some other methods seem to require the brackets, eg
I also note that method invocations that return an object, eg
' Create child label control for text box.
Set ctlLabel = CreateControl(frm.Name, acLabel, , _
ctlText.Name, "NewLabel", intLabelX, intLabelY)
seem to require the round brackets.
What is the rule and where do I look it up? Any ideas folks?
VB doesn't allow parentheses when calling Sub's unless you preface the call with the Call statement. For example, the following is a valid use:
Call DoCmd.GoToRecord(, , acNewRec)
When a function call returns a value and you want to obtain that value, you'll need to use parentheses.
With your PSet call, you aren't actually using parentheses on the function, the parentheses are used as a parameter. In other words, (intI, sngMidPt) is a essentially treated as a single parameter in PSet. For example, the following is a valid call:
Me.PSet (intI, sngMidPt), vbBlue
Basically, it's easiest to skip the parentheses unless it is a function that you are trying to capture the return value for.
Many methods take one or more arguments. An argument provides the method with additional information for its operation. If the method returns a value or an object, you must enclose its argument list in parentheses; otherwise you should omit the parentheses.