访问宏不起作用?
我在模块中创建了一个函数:
Public Function createTable()
Dim db As Database
Dim tdf As TableDef
Dim fld As Field
Set db = CurrentDb()
Set tdf = db.CreateTableDef("161-0363")
Set fld = tdf.CreateField("SKUS", dbText, 30)
tdf.Fields.Append fld
Set fld = tdf.CreateField("Count", dbInteger)
tdf.Fields.Append fld
End Function
然后使用“RunCode”在宏中调用该函数。但是当我运行宏时没有创建表? 有人可以帮我吗?
谢谢!
I created a function in a module:
Public Function createTable()
Dim db As Database
Dim tdf As TableDef
Dim fld As Field
Set db = CurrentDb()
Set tdf = db.CreateTableDef("161-0363")
Set fld = tdf.CreateField("SKUS", dbText, 30)
tdf.Fields.Append fld
Set fld = tdf.CreateField("Count", dbInteger)
tdf.Fields.Append fld
End Function
Then called this function in a macro using "RunCode". But no table is created when I run the macro?
Can anyone help me out?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
在您的宏设计视图中,您应该显示
RunCode
,然后在您的Function Name
中应该显示createTable()
该代码是否创建一个表如果你在没有宏的情况下运行它?
编辑:
将您的代码更新为此然后运行您的宏
我刚刚测试了上面的代码并创建了表格。您需要添加最后几行代码才能使其正常工作。
On your Macro Design View, you should have it say
RunCode
, then in yourFunction Name
it should saycreateTable()
Does the code create a table if you run it without a macro?
EDIT:
Update your code to this then run your macro
I just tested the above code and it created the table. You needed to add the last lines of code to get it to work.