Why won't this code work

geoffcodd

Registered User.
Local time
Today, 11:46
Joined
Aug 25, 2002
Messages
87
I HAve the following code which should in turn open up a report depending on the selection made in three combo boxes but for some reason it won't work

stDocName = DLookup("[Report_Name]", "Report_Config", "[Report_Group_No] = " & Forms!Report_Criteria_Selection!Group_Selection & "'" And "[Report_Type_No] = '" & Forms!Report_Criteria_Selection!Type_Selection & "'" And "[Lookup_ID]= '" & Forms!Report_Criteria_Selection!Criteria_Selection & "'")

Report_Group_No = Numeric
Report_Type_No = Numeric
Lookup_ID = Text

Any help much appreciated

Thanks
Geoff
 
Geoff,

You are only assigning a value to a string. It is not even
trying to run the report.

Why don't you base your report on a query.

Have the query use your form controls as the
criteria.

Then when you hit the command button to run
the report, just launch it and it will use
the values from your OPEN form.

hth,
Wayne
 
Wayne's suggestion is a very good one. This reply is just to troubleshoot your string. Try this (it doesn't seem to format properly in Preview but you should get the idea).

stDocName = DLookup("[Report_Name]", "Report_Config", "[Report_Group_No] = " & Forms!Report_Criteria_Selection!Group_Selection & " And [Report_Type_No] = " & Forms!Report_Criteria_Selection!Type_Selection & " And [Lookup_ID]= '" & Forms!Report_Criteria_Selection!Criteria_Selection & "'")

Paul
 
You have syntax errors. You would have seen that if you had used the debug window to display stDocName. Assuming that all three criteria are text:

stDocName = DLookup("[Report_Name]", "Report_Config", "[Report_Group_No] = 1" & Forms!Report_Criteria_Selection!Group_Selection & "' And [Report_Type_No] = '" & Forms!Report_Criteria_Selection!Type_Selection & "' And [Lookup_ID]= '" & Forms!Report_Criteria_Selection!Criteria_Selection
& "'")
 

Users who are viewing this thread

Back
Top Bottom