Access DLookup produces runtime error 2471

gbnorton
gbnorton used Ask the Experts™
on
Hi,
this routine fails with runtime error 2471.  What might be wrong?
Thanks,
Brooks

Private Sub Print_Label_Click()
    Dim strPartNumber As String
    Dim strExists As Integer
    strPartNumber = Me.cboPN
    ' This section sees if part number is axial leaded or chip
    ' See if the diode part number exists in the diodes table
    ' If it is an axial leaded part use Glassing Furnace Diode Label
    ' If it is a chip use Glassing Furnace Chip Label
    strExists = DCount("[P_Number]", "Diodes", "[P_Number] = strPartNumber")
    If strExists <> 0 Then
    Stop
        DoCmd.OpenReport "Glassing Furnace Diode Label", acViewNormal, , "[ID]=" & Me.ID
    Else
    Stop
        DoCmd.OpenReport "Glassing Furnace Chip Label", acViewNormal, , "[ID]=" & Me.ID
    End If
   
End Sub
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Must put variables outside the dblquptes and text values must be enclosed in single quotes:  

 strExists = DCount("[P_Number]", "Diodes", "[P_Number] ='" &  strPartNumber & "'")

Author

Commented:
Perfect.  Thanks for looking on Sunday!
Brooks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial