开发者

Compile time: Syntax error

I am able to add controls to a form when it is loaded. I need these controls to be to be catagorized so the user only can see a few at a time. My first thought was to attached the controls to particular tabs. Not sure why the syntax is off in the following code. Thanks for the help!

Private Sub Enter_Records_Click()

Dim stDocName As String
Dim tabPage As String
Dim tabNum As Integer
Dim i As Integer
Dim passedTabName As String

stDocName = "CLForm"
tabPage = "tabControl.tabPage"
stTabName = stDocName & tabPage
tabNum = 8 'the number of tabs on the "CLForm"

DoCmd.OpenForm stDocName, acDesign
For i = 0 To tabNum - 1
    passedTabName = stTabName & i
    CreateKeywords (stDocName, passedTabName)
Next i
DoCmd.Close acForm, stDocName, acSaveYes
DoCmd.OpenForm stDocName, acNormal

End Sub

Public Sub CreateKeywords(frmName As String, tabName As String)

Another idea that might be better, simply having buttons that 开发者_高级运维show one category of controls at a time. Would this be easier?


You need to use the Call keyword when calling a method with more than one parameter and using parentheses.

For example, these would work:

Call CreateKeywords(stDocName, passedTabName)
CreateKeywords stDocName, passedTabName
//Example of using parentheses with one parameter
Msgbox (stDocName) 

Welcome to the wonderful world of VBA. ;)


It is best be careful with calling arguments and parentheses:

Public Sub CallingSub()
   CallingArg = "ABCDEF"
   CalledFunc CallingArg
   Debug.Print CallingArg ''Result: 987654

   CallingArg = "ABCDEF"
   CalledFunc (CallingArg) ''Result: ABCDEF
   Debug.Print CallingArg

   CallingArg = "ABCDEF"
   Call CalledFunc(CallingArg)
   Debug.Print CallingArg ''Result: 987654
End Sub

Public Function CalledFunc(CalledFuncArg)
   CalledFuncArg = "987654"
   CalledFunc = "Return"
End Function
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜