dlookup giving error

rehanemis

Registered User.
Local time
Tomorrow, 01:39
Joined
Apr 7, 2014
Messages
195
Hi,

I am using dlookup to retrieve value from table. I have set after-update even when user select a department name and got the department id into the field by using dlookup.
Code:
Me.DepID = DLookup("DepID", "DepMain", "DepName.value='" & Me.Department.Value & "'")

Just the problem is when apostrophe is used in department name it gives error.

Can anyone give solution how to solve the issue.

Thanks and waiting of your kind response.
 

Attachments

  • error3075.JPG
    error3075.JPG
    51 KB · Views: 73
Me.DepID = DLookup("DepID", "DepMain", "DepName = '" & Me.Department.Value & "'")
 
Hi,

But it is the same code i have posted. Can you please tell me how to resolve the issue when apostrophe (') is used in criteria and how to resolve it)
 
To be honest it would be better if your department was taken from a table with a DeptID so that the text description of the department would make no difference.

Table Departments
FieldName | Data Type
DeptID | PK unique
DeptDescription | text

You then store the DeptID in your main table rather than the name in text. If the Dept name is ever changed you just adjust the text description and miraculously all the details will update accordingly :)
 

Users who are viewing this thread

Back
Top Bottom