Ms access 具有多个dlookup条件的错误
此代码为带有matchstr\t的dlookup生成运行时错误3464。我不明白为什么matchstr_v看起来很好用。有报价吗?目前,我所要做的就是使用dlookup来标记约会的重复开始时间Ms access 具有多个dlookup条件的错误,ms-access,duplicates,vba,Ms Access,Duplicates,Vba,此代码为带有matchstr\t的dlookup生成运行时错误3464。我不明白为什么matchstr_v看起来很好用。有报价吗?目前,我所要做的就是使用dlookup来标记约会的重复开始时间 Dim i, j, clientid, therid As Integer Dim origin_date, apptdate As Date Dim slotday, apptype, venue, matchstr_v, matchstr_t As String Dim slottime As Da
Dim i, j, clientid, therid As Integer
Dim origin_date, apptdate As Date
Dim slotday, apptype, venue, matchstr_v, matchstr_t As String
Dim slottime As Date
Dim appt(25) As Date
Dim db As Database
Dim rst As Recordset
Dim test As Variant
origin_date = Date
slotday = Me.slot_day.Value
slottime = Me.slot_time.Value
clientid = Me.Client_ID.Value
therid = Me.Therapist_ID.Value
venue = Me.venue.Value
apptype = "continuation"
slottime = Format(slottime, "Short Time")
For i = 1 To 7
apptdate = Date + i
If Weekday(apptdate, 2) = slotday Then
'set up stuff
For j = 0 To 25
appt(j) = apptdate + (j * 7)
Set db = CurrentDb()
Set rst = db.OpenRecordset("Dummy")
Debug.Print "[therapist ID] = " & therid
matchstr_v = "[appt date]= #" & appt(j) & "# AND [appt time] = #" & slottime & "# AND [venue] = '" & venue & "'"
matchstr_t = "[appt date]= #" & appt(j) & "# AND [appt time] = #" & slottime & "# AND [therapist ID] = " & therid
Debug.Print matchstr_t
If Not IsNull(DLookup("[dummy ID]", "Dummy", matchstr_v)) Then
' do more stuff
ElseIf Not IsNull(DLookup("[dummy ID]", "Dummy", matchstr_t)) Then
' do more stuff
Else
rst.AddNew
rst.Fields("appt date") = appt(j)
rst.Fields("appt time") = slottime
rst.Fields("Client ID") = clientid
rst.Fields("Therapist ID") = therid
rst.Fields("appt type") = "continuation"
rst.Fields("attendance") = "scheduled"
rst.Fields("venue") = venue
'Debug.Print rst.Fields("appt date")
rst.Update
test = (DLookup("[dummy ID]", "Dummy", matchstr_v))
Debug.Print test
End If
rst.Close
db.Close
Next j
Else
End If
Next i
[治疗师ID]的数据类型是什么
似乎数据类型与therid的值不匹配。在这种情况下,您可能只是缺少一个
matchstr_t=[appt date]=&apptj&和[appt time]=&slottime&和[治疗师ID]=&therid[治疗师ID]是我正在处理的表中的一个字段-绑定值是一个整数。请告诉我们调试的内容。当DLookup出现错误时,打印matchstr_t.[appt date]=2013年5月27日,[appt time]=16:00和[治疗师ID]=2创建和测试此新访问查询时会发生什么情况。。。从假人中选择*,其中[appt date]=2013年5月27日,[appt time]=16:00,[治疗师ID]=2。。。如果[ID]的数据类型是文本而不是数字。则可能会出现错误3464,条件表达式中的数据类型不匹配。非常感谢-[治疗师ID]数据类型在原始表中是'number',但是当我创建dummy来处理这段代码时,我没有足够小心地设置数据类型。问题解决了。我将研究如何接受/comment.debug.print matchstr\t给出的答案