Dlookup question

jwillet1

Registered User.
Local time
Today, 03:52
Joined
Nov 8, 2013
Messages
35
Attached is a picture of a query I have. It returns the number of test days a program has used, stored in Days. I have a form, second attachment, where a user is able to select which program they want to lookup, this is shown in a form with comboBox dropdown. When the user selects which program they want a, graph, made from the query in the third attachment, appears, indicating some other information, and works just fine. I have another text box that is supposed to show the value in the query for total test days where the comboBox value selected earlier matches the appropriate program from the test days query. The code I'm using is below, however it does not indicate the correct value just

Code:
=DLookUp([Days],[qryTotalTestDaysPerProgram],"[programNumber] = '" & [Form]![cboProgramNumberReport] & "'")

Its giving me "#Name?" in the text box instead of the days value.

Tips appreciated.
 

Attachments

  • Total Days.png
    Total Days.png
    3.7 KB · Views: 91
  • Days question.png
    Days question.png
    35.3 KB · Views: 87
  • Graph Query.png
    Graph Query.png
    8.8 KB · Views: 89
  • Total days design view.png
    Total days design view.png
    15.1 KB · Views: 91
The first two arguments of the DLookup also need to be in quotes.
 
Thank you very much.

In case anyone finds this later in their search for a solution, pbaldy was right, just a dumb syntax error.

One other thing I had to do, in my situation, was that due to the "choice of program" being on the currently used form, I had to use dlookup in VBA on an "afterUpdate" event in the selection combobox. Otherwise to textbox would error out.

Code:
txtTotalTestDays = DLookup("SumOfDays", "qryTotalTestDaysPerProgram", "programNumber = '" & Forms!formVehicleByProgramByPhase!cboProgramNumberReport & "'")
 

Users who are viewing this thread

Back
Top Bottom