Dlookup Crashing

Hi ,
See attached.
Click on frmDetail.
Then click on the yellow field.
This is a part code which should then find a "CostPrice" from tblSpareParts.

However, it gives and error when the part code is chosen.
I appreciate that the data strucures are not great.
However, could some one advise how I can stop my dlookup from crashing.
Keylight4.zip
Patrick O'DeaAsked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Connect With a Mentor Database ArchitectCommented:
Private Sub Part1_BeforeUpdate(Cancel As Integer)

If Len(Me.Part1 & "") > 0 Then
Me.Price1 = DLookup("[CostPrice]", "tblSPareParts", "[PartCode] = " & Chr(34) & Me.Part1 & Chr(34))
Else
Me.Price1 = 0
End If

End Sub
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
I don't seem to get an error. How exactly can I reproduce the issue?

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Here you go:

Me.Price1 = DLookup("[CostPrice]", "tblSPareParts", "[PartCode] = " & Chr(34) & Me.Part1 & Chr(34))
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
Patrick O'DeaAuthor Commented:
Just run frmDetail and then click on the dropdown that is yellow !

Gives error 2471


Is this not happening with you??
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Fixed ... see post above...

mx
0
 
Patrick O'DeaAuthor Commented:
Perfect ! Thanks again!
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
You are welcome.

Remember, Text criteria has to be surrounded with double quotes ( Chr(34) ) and Date criteria has to be enclosed with #'s

mx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.