DateSerial编译错误 [英] DateSerial Compile Error

查看:112
本文介绍了DateSerial编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个预期的编译错误=使用以下代码:

I have a compile error expected = with the following code:

Option Compare Database
Option Explicit

Public Sub TestDateSerial()

Debug.Print dateserial(2017, 3, 6)



End Sub

代码应该是正确的,所以我不明白错误。我在我的查询和表格中有一个名为"再次使用"的列,其中包含不同的日期,包括日期序列中要求的日期,所以我不知道是否可能会混淆两者?

The code should be correct so I don't understand the error. I have in my query and table a column called 'Use Again' that contains different dates including the one asked for in the date serial so I don't know if maybe it is confusing the two?

此外,我收到另一个编译错误预期变量或过程而不是模块,其中包含以下代码:

Furthermore, I receive another compile error expected variable or procedure not module with the following code:

Private Sub InitVariables()
On Error GoTo ErrorHandler

intMonth = Me.cboMonth
intYear = Me.cboYear
lngFirstDayOfMonth = CLng(dateserial(intYear, intMonth, 1))
intFirstWeekday = getFirstWeekday(lngFirstDayOfMonth)
intDaysInMonth = getDaysInMonth(intMonth, intYear)


ExitSub:
    Exit Sub


ErrorHandler:
    MsgBox "There has been an error. Please reload the form"
    Resume ExitSub
    

End Sub

我已在下划线中显示错误。

I have underlined where the errors appear.

非常感谢任何帮助!

推荐答案

通常当我们看到像这样的奇怪错误时,这是​​因为参考问题。 我首先尝试编译您的VBA项目以确保没有问题。 我还会检查我的项目参考(工具 - >参考)并确保没有标记为
为MISSING。
Usually when we see weird errors like this it is because of reference issues.  I'd start by trying to compile your VBA project to ensure there are no issues.  I'd also check my project references (Tools -> References) and ensure none are marked as MISSING.


这篇关于DateSerial编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆