Solved DLookup Error (1 Viewer)

Momma

Member
Local time
Today, 16:17
Joined
Jan 22, 2022
Messages
114
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 & "'")
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 01:17
Joined
Feb 28, 2001
Messages
27,202
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.
 

Momma

Member
Local time
Today, 16:17
Joined
Jan 22, 2022
Messages
114
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

Top Bottom