DLOOKUP OVERFLOW 6

时间:2015-12-17 01:03:24

标签: sql database ms-access access-vba

我使用两个未绑定的textboxes作为输入,第三个textbox作为输出。 我的表包含Dlookup适用的大约19K的recods。但是如果输入包含来自大约5K的记录值,我将收到溢出6错误。任何帮助?这是代码......

Private Sub Command4_Click()
On Error GoTo Message
Dim r As Integer, s As String
Dim u As String
r = Text0.Value
s = Text2.Value
u = DLookup("ActionBy", "RAW", "[requestid]=" & r & " AND [Type]='" & s & "'")
Me.Text7 = u
Exit Sub
Message:
MsgBox Err.Description & " " & Err.Number
MsgBox "Make sure you've entered the correct Values", , "Static Error"
End Sub

1 个答案:

答案 0 :(得分:3)

您的代码可能由于多种原因而失败。试试这个更强大的版本:

Private Sub Command4_Click()

    ' Uncomment this line when code is verified:
    ' On Error GoTo Message

    Dim r As Long
    Dim s As String
    Dim u As Variant

    r = Nz(Text0.Value, 0)
    s = Nz(Text2.Value)
    u = DLookup("ActionBy", "RAW", "[requestid]=" & r & " AND [Type]='" & s & "'")
    Me.Text7.Value = u
    Exit Sub

Message:
    MsgBox Err.Description & " " & Err.Number
    MsgBox "Make sure you've entered the correct values.", , "Static Error"

End Sub

此外,将Command4重命名为有意义的内容。