From: Douglas J. Steele on
Since BatchNum is text, the value being passed must be in quotes:

Me.txtBinsScanned = DCount("[BatchNum]", "[tblPreSortBatchBackup]",
"[BatchNum]='" & [Forms]![frmTraceBox]![txtBatch] & "'")

Exagerated for clarity, that's

"[BatchNum]= ' " & [Forms]![frmTraceBox]![txtBatch] & " ' ")

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"FatMan" <FatMan(a)discussions.microsoft.com> wrote in message
news:3AF541DE-E5CD-4A03-85AF-E4A007C40758(a)microsoft.com...
> Hi all:
> The code listed below is giving me a "Data Type mismatch in criteria
> expression" error.
>
> Code:
> Me.txtBinsScanned = DCount("[BatchNum]", "[tblPreSortBatchBackup]",
> "[BatchNum]=" & [Forms]![frmTraceBox]![txtBatch])
>
>
> Where:
> BatchNum data type is text
>
> TxtBatch is a text box on my form that is getting its value through a
> dlookup function and the results being returned are from a text field from
> a
> different table. It works and the code for it is:
>
> Me.txtBatch = DLookup("[InFriutTransLog]", "[tblIntake]", "[IntakeID]=" &
> [Forms]![frmTraceBox]![txtIntakeID])
>
> All help is greatly appreciated.
>
> Thanks,
> FatMan
>


From: FatMan on
Doug:
You da man!

Thanks,
FatMan

"Douglas J. Steele" wrote:

> Since BatchNum is text, the value being passed must be in quotes:
>
> Me.txtBinsScanned = DCount("[BatchNum]", "[tblPreSortBatchBackup]",
> "[BatchNum]='" & [Forms]![frmTraceBox]![txtBatch] & "'")
>
> Exagerated for clarity, that's
>
> "[BatchNum]= ' " & [Forms]![frmTraceBox]![txtBatch] & " ' ")
>
> --
> Doug Steele, Microsoft Access MVP
> http://www.AccessMVP.com/DJSteele
> (no e-mails, please!)
>
> "FatMan" <FatMan(a)discussions.microsoft.com> wrote in message
> news:3AF541DE-E5CD-4A03-85AF-E4A007C40758(a)microsoft.com...
> > Hi all:
> > The code listed below is giving me a "Data Type mismatch in criteria
> > expression" error.
> >
> > Code:
> > Me.txtBinsScanned = DCount("[BatchNum]", "[tblPreSortBatchBackup]",
> > "[BatchNum]=" & [Forms]![frmTraceBox]![txtBatch])
> >
> >
> > Where:
> > BatchNum data type is text
> >
> > TxtBatch is a text box on my form that is getting its value through a
> > dlookup function and the results being returned are from a text field from
> > a
> > different table. It works and the code for it is:
> >
> > Me.txtBatch = DLookup("[InFriutTransLog]", "[tblIntake]", "[IntakeID]=" &
> > [Forms]![frmTraceBox]![txtIntakeID])
> >
> > All help is greatly appreciated.
> >
> > Thanks,
> > FatMan
> >
>
>
> .
>