DLookup Issue in VBA

skwilliams

Registered User.
Local time
Yesterday, 19:07
Joined
Jan 18, 2002
Messages
516
I have a form where I select a date from an unbound combo box (Combo80). * This is a list of week ending dates. When a date is selected I need Text16 to fill with the total for that date from qryOCParts1.

Here's sample data from the table referenced.
SumOfCount EndOfWeek
3644 3/31/2012
6959 3/24/2012
7488 3/17/2012
7163 3/10/2012
6888 3/3/2012

Result should be "If I select 3/24/2012, Text16 fills with 6959.

Here's the VBA code.
Code:
Private Sub Combo80_AfterUpdate()
Dim WkEnd As Date
Dim Yr As Integer
Dim PvsDate As Date

WkEnd = Combo80.Column(0)
Yr = Combo80.Column(1)
PvsDate = Combo80.Column(2)

Text16 = DLookup("[SumOfCount]", "qryOCParts1", "EndOfWeek=WkEnd")
End Sub

Here's my problem, I keep getting this error.
Run-time error '2471':
The expression you entered as a query parameter produced this error:
'WkEnd':confused:
 
Got it working by running the Dlookup through the textbox control source instead of VBA. Same code works there. Weird. Thanks for the help!
 
Hi helpers

I am facing a problem
2 tables LU Product and Sales Point
I want the price from LU product populates when I enter the product in Sales point form
The code I have written is as below
Private Sub Price_AfterUpdate() Product = DLookup("Product", "LU Product", "Price=" & Price) End Sub It works If we enter the price and the product names populates
Private Sub combo10_AfterUpdate()
Price = DLookup("Price", "LU Product", "Product=" & Combo10)
End Sub

The combo10 is Product field in Form
does not works and gives error 2471
The error message quotes
the run time error 2471
The expression you entered as aquery parameter produce this error: Injection (name from product list)
 
Hi helpers

I am facing a problem
2 tables LU Product and Sales Point
I want the price from LU product populates when I enter the product in Sales point form
The code I have written is as below
Private Sub Price_AfterUpdate() Product = DLookup("Product", "LU Product", "Price=" & Price) End Sub It works If we enter the price and the product names populates
Private Sub combo10_AfterUpdate()
Price = DLookup("Price", "LU Product", "Product=" & Combo10)
End Sub

The combo10 is Product field in Form
does not works and gives error 2471
The error message quotes
the run time error 2471
The expression you entered as aquery parameter produce this error: Injection (name from product list)
This is the third thread spammed, please desist, it's only going to get you a bad name..
 
Error in current record print command

The following code works well in office2007 but gives error in officeXP as Access is closed and asking to save the back up.
Is there any difference in CODE for XP & W7

Private Sub Command30_Click()
Dim strDocName As String
Dim strWhere As String
strDocName = "BillOpenPriceNEW"
strWhere = "[Sr]=" & Me!Sr
DoCmd.OpenReport strDocName, acPrint, , strWhere
End Sub
Please help me
 

Users who are viewing this thread

Back
Top Bottom