Solved DLookup Error

Momma

Member
Local time
Today, 23:24
Joined
Jan 22, 2022
Messages
130
Hi guys
I get a Data type mismatch in criteria expression error in my Dlookup expression.
When I add a Toggle Breakpoint and step over each line all the values are there and correct. The Dlookup picks up the Motherid but not the Litternumber.
I just can't see what I'm doing wrong.
Code:
    Dim Motherid As Long
    Motherid = Me.DogID
    Dim Mother As String
    Mother = Me.CallName
    Dim Litternumber As Long
    Litternumber = InputBox("Enter Litter number")
    Dim ReproID As Long
    ReproID = DLookup("reproductionid", "[tblreproduction]", "[motherid]='" & [Motherid] & "' and [mlittercount] = '" & Litternumber & "'")
 
If [mlittercount] is a number (and declaring Litternumber as a LONG suggests it might be), your single-quotes for that part of the expression might be inappropriate.
 
If [mlittercount] is a number (and declaring Litternumber as a LONG suggests it might be), your single-quotes for that part of the expression might be inappropriate.
That is indeed the case. It's working now!
Thank you for your help.
 

Users who are viewing this thread

Back
Top Bottom