Problem with DLookup cutting off the last character of the criteria

Thirith

Board Regular
Joined
Jun 9, 2009
Messages
120
Office Version
  1. 365
Platform
  1. Windows
On my main form, I've got a date field that should update another field based on a range of dates. The field is called txtDateSubmissionPhase1 and it should look up information in the table tblStageLookup, which has these relevant columns: StageDescription and StageEndDate.

This is the DLookup code I'm using:
Code:
varTest = DLookup("[StageDescription]", "tblStageLookup", "[StageEndDate] <= # " & [txtDateSubmissionPhase1] & "#")

However, weirdly I keep getting an error - and in this error it looks like the final character (in this case the second #) is omitted from the criteria.

Can anyone here tell me why this is happening and how I can avoid it? It seems a pretty strange thing for the code to do, but I have to admit that I'm always a bit at a loss with respect to code that needs to be in string format.
 
I agree, it is strange, but you could spend days getting to the bottom of it. :confused:

Whenever I post for help, I copy and paste and then perhaps change any static data for privacy reasons? My typing is way to slow to do that. :)
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top