Share via

Compare two dates in different tables

Anonymous
2017-08-14T19:55:25+00:00

Hi

I try to create macro, that after update some field of date in form that dependen in one table than compare in another table - field of date, and if less so up message box. It's looks some like this:

[table1]![date1] < [table2]![table2]

Message box

please chek the date

But when I try this, I get a error: "Microsoft access cannot find the name you entered in the expression" But I build it with expression builder!

Thank you

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

13 answers

Sort by: Most helpful
  1. Anonymous
    2017-08-15T16:43:02+00:00

    You did not respond to question of how/what fields the tables are related.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2017-08-15T13:33:58+00:00

    Thank you for answer, 

    Query not my way, I need to prevent incorrect entry.

     So you suggest use DLookUp(), but how?

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2017-08-15T13:30:56+00:00

    Thank for answer,

    Table 1 main table and table 2 is related. Relationship: one to many. In table1, date 1 is final date. Unlike in table 2, date 2, can be some date. 

    I want to prevent incorrect entry. Query is not so good.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2017-08-15T01:10:58+00:00

    More information please. Is there any link between the two tables? If you're updating one record in Table1, how can you identify which record in Table2 should be used for the comparison? What are the relevant fields in your two tables, and how (if at all) are the tables related?

    In any case, a Macro is probably not the right tool: you may be able to do this with a Query and if not, with some very easy VBA code.

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2017-08-14T20:46:15+00:00

    Where are you needing to perform this comparison?

    You might be able to use DLookUp() to get the value and compare them.

    Another, preferred approach, is to build a query that extracts both values and then you can compare them directly to one another.

    Was this answer helpful?

    0 comments No comments