On a form, I'm trying to compare two dates. Date A is located in Table A, and Date B is located in Table B. They are related by both tables having the column LinkedColumn. LinkedColumn is a PK in Table B, but not in Table A.
The record source of the form is Table A; so I am trying to bring Date B onto the form using Dlookup. I'd like to avoid changing the record source because the form has a lot of other sections that rely on Table A.
The strangest part is that sometimes it works and sometimes it doesn't.
Here is the actual code of what I've been trying:
Code:
Dim dateB as variant \\using As Date was also not working
dateB = Dlookup("Date B", "Table B", "Table B.LinkedColumn = Table A.LinkedColumn"
dateB = Dlookup("Date B", "Table B", "LinkedColumn = Table A.LinkedColumn"
dateB = Dlookup("Date B", "Table B", "LinkedColumn = Table B.LinkedColumn"
dateB = Dlookup("Date B", "Table B", "LinkedColumn = " & Dlookup("LinkedColumn", "Table A"))
dateB = DLookup("Date B", "Table B", "TableB.LinkedColumn =" & Forms![Form]!LinkedColumn)
There's probably several other combinations that I've tried that I am forgetting. Every error either says there is a operator error in the criteria part or an invalid use of null.