0

I am trying to set up a macro and expression to update a form field when an existing record is selected in a different field. Specifically I have a drop down on my form that allows the user to select a "request" object from my request table. When they select it, it automatically fills the projCourseID field with the corresponding reqCourseID from the request object.

The way I have it set up now is to run a SetProperty macro AfterUpdate on the reqID dropdown. I have the macro filled out like this:

Control Name: projCourseID
Property: Value
Value =DLookUp("[reqCourseID]","Training Requests","[reqID] =" & [Forms]![New Project]![reqID])

reqID is the primary key to Training Requests table. When I try to run this I get a 2950 error. I feel like I am missing something small and obvious. Wjat am I doing wrong?

CodeJack
  • 19
  • 2
  • 5

1 Answers1

0

If other things are okay, I think you are missing Single Quote (') in criteria part. see below expression.

Value =DLookUp("[reqCourseID]","Training Requests","[reqID] ='" & [Forms]![New Project]![reqID] & "'")

Remember in DLookUP function criteria use variant data type. So, you have to use Single Quote (')

Harun24hr
  • 30,391
  • 4
  • 21
  • 36
  • However for some reason when I try to do almost the exact same thing in a different form the error pops up again:
    > Value=DLookUp("[projTarget]","Project","[projID] ='" & [Forms]![New Task]![projID] & "'")'
    – CodeJack Feb 04 '16 at 16:15
  • Its showing an extra `Single quote` after bracket. You should define a `variant` type variable, then use that variable as criteria rather than `[Forms]![New Task]![projID]` Do you check other codes? Can you please put more codes here? So that we can check. – Harun24hr Feb 04 '16 at 17:29