SteveL13
asked on
#Error in a report field
Can someone spot my issue here? I'm getting a #Error when I use this for the control on a report field:
=DLookUp("[QtyTransferred] ","query2" ,"[OwnerNa me] = " & "John Doe ABC" & " AND [TransDate] = '" & [Reports]![rptInventoryOwn ership]![t xtCropYear ] & "'")
I've also tried:
=DLookUp("[QtyTransferred] ","query2" ,"[OwnerNa me] = " & "John Doe ABC" & " AND [TransDate] =#" & [Reports]![rptInventoryOwn ership]![t xtCropYear ] & "#")
=DLookUp("[QtyTransferred]
I've also tried:
=DLookUp("[QtyTransferred]
ASKER
I forgot one critera... Crop
Here is what I have now but getting #Error
=DLookUp("[QtyTransferred] ","query2" ,"[OwnerNa me] = " & "'John Doe ABC'" & " AND [Crop] = [txtCrop2] AND [TransDate] = '" & [Reports]![rptInventoryOwn ership]![t xtCropYear ] & "'")
Here is what I have now but getting #Error
=DLookUp("[QtyTransferred]
What is txtCrop2? A VBA variable? A table column? A control on the form?
»bp
»bp
ASKER
Is a control on the report.
Double check me, but I think that would be:
»bp
=DLookUp("[QtyTransferred]","query2","[OwnerName] = " & "'John Doe ABC'" & " AND [Crop] = '" & [Reports]![rptInventoryOwnership]![txtCrop2] & "' AND [TransDate] = '" & [Reports]![rptInventoryOwnership]![txtCropYear] & "'")
»bp
You need a properly formatted string expression for your date value:
=DLookUp("[QtyTransferred]","query2","[OwnerName] = 'John Doe ABC' AND [TransDate] = #" & Format([Reports]![rptInventoryOwnership]![txtCropYear], "yyyy\/mm\/dd") & "#")
or - if it is not a date but a year:=DLookUp("[QtyTransferred]","query2","[OwnerName] = 'John Doe ABC' AND Year([TransDate]) = " & [Reports]![rptInventoryOwnership]![txtCropYear] & "")
ASKER
Bill: Still getting #Error
Gustav, per above: (Crop has to be added as a criteria)
I forgot one criteria... Crop
Here is what I have now but getting #Error
=DLookUp("[QtyTransferred] ","query2" ,"[OwnerNa me] = " & "'John Doe ABC'" & " AND [Crop] = [txtCrop2] AND [TransDate] = '" & [Reports]![rptInventoryOwn ership]![t xtCropYear ] & "'")
Gustav, per above: (Crop has to be added as a criteria)
I forgot one criteria... Crop
Here is what I have now but getting #Error
=DLookUp("[QtyTransferred]
Just add it in a similar way:
And if year, not date, adjust to my previous code.
=DLookUp("[QtyTransferred]","query2","[OwnerName] = 'John Doe ABC' AND Crop = '" & [Reports]![rptInventoryOwnership]![txtCropYear] & "' AND [TransDate] = #" & Format([Reports]![rptInventoryOwnership]![txtCropYear], "yyyy\/mm\/dd") & "#")
If Crop is not text but number, remove the single quotes.And if year, not date, adjust to my previous code.
ASKER
Frustrating. Still getting #Error with:
Note: Crop is text. CropYear is text.
=DLookUp("[QtyTransferred]","query2","[OwnerName] = 'John Doe ABC' AND [Crop] = '" & [Reports]![rptInventoryOwnership]![txtCrop2] & "' AND [TransDate] = " & [Reports]![rptInventoryOwnership]![txtCropYear] & "")
Note: Crop is text. CropYear is text.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Are you sure there is a match in the data for the values you are passing?
»bp
»bp
Open in new window
»bp