Error in VBA code

  • Thread starter Thread starter Ling
  • Start date Start date
L

Ling

I think I need some help here.
Below is my code:

Dim varFoldedSize As Variant
Dim intCheckNoOfSheets As Integer

'check if txtSizeI is checked
If chkSizeI = -1 Then
varFoldedSize = DLookup("[qryNoOfPrintedPaperSheets
(Folded)]!
[FoldedPrintedPaperSize]", "[qryNoOfPrintedPaperSheets
(Folded)]", "")
Else
varFoldedSize = txtSize.Value
End If
MsgBox (varFoldedSize)

intCheckNoOfSheets = DLookup("[qryTEST]![No of Printed
Paper Sheets/25''*37'']", "[qryTEST]", "[PrintedPaperSize]
=" & varFoldedSize)

Is there any syntax error in this line:
txtCoverSheets = DLookup("[qryTEST]![No of Printed Paper
Sheets/25''*37'']", "[qryTEST]", "[PrintedPaperSize] =" &
varFoldedSize)?

Whenever, I execute this code an error msg pops up,
saying "You canceled the previous operation."

Thanx

Regards,
Ling
 
Access is unable to interpret this line:
varFoldedSize =
DLookup("[qryNoOfPrintedPaperSheets(Folded)]![FoldedPrintedPaperSize]",
"[qryNoOfPrintedPaperSheets(Folded)]", "")

The first argument needs to be just the field name.
The 2nd argument looks okay.
Just omit the 3rd argument if you have no criteria to apply.

Try:
varFoldedSize = DLookup("[FoldedPrintedPaperSize]", _
"[qryNoOfPrintedPaperSheets(Folded)]")
 
Back
Top