Hi.
I have a query named "ClientWrkHrs":
SELECT ClientCal.Abbr, ClientCal.Start_Date, ClientCal.StartTime, ClientCal.EndTime, DateDiff("n",[StartTime],[EndTime])/10+1 AS Slots
FROM ClientCal
WHERE (((ClientCal.Abbr) Like "*" & "jo" & "*"))
ORDER BY ClientCal.StartTime;
This returns the records that I want, limited to those with "jo" in the field Abbr.
However, I want to make the criteria less specific, so I tried inserting a reference to a form field:
SELECT ClientCal.Abbr, ClientCal.Start_Date, ClientCal.StartTime, ClientCal.EndTime, DateDiff("n",[StartTime],[EndTime])/10+1 AS Slots
FROM ClientCal
WHERE (((ClientCal.Abbr) Like "*" & [Forms]![ClientAppt]![Cname] & "*"))
ORDER BY ClientCal.StartTime;
If I run the query in isolation and enter "jo" in the prompt it works fine. However, If I run the query from a command button on the form I get an error: "Too few parameters. Expected 1". The command button calls a module and it fails at line:
Set RS = db.OpenRecordset("ClientWrkHrs")
Does anyone have any ideas what could be wrong?
Thanks
I have a query named "ClientWrkHrs":
SELECT ClientCal.Abbr, ClientCal.Start_Date, ClientCal.StartTime, ClientCal.EndTime, DateDiff("n",[StartTime],[EndTime])/10+1 AS Slots
FROM ClientCal
WHERE (((ClientCal.Abbr) Like "*" & "jo" & "*"))
ORDER BY ClientCal.StartTime;
This returns the records that I want, limited to those with "jo" in the field Abbr.
However, I want to make the criteria less specific, so I tried inserting a reference to a form field:
SELECT ClientCal.Abbr, ClientCal.Start_Date, ClientCal.StartTime, ClientCal.EndTime, DateDiff("n",[StartTime],[EndTime])/10+1 AS Slots
FROM ClientCal
WHERE (((ClientCal.Abbr) Like "*" & [Forms]![ClientAppt]![Cname] & "*"))
ORDER BY ClientCal.StartTime;
If I run the query in isolation and enter "jo" in the prompt it works fine. However, If I run the query from a command button on the form I get an error: "Too few parameters. Expected 1". The command button calls a module and it fails at line:
Set RS = db.OpenRecordset("ClientWrkHrs")
Does anyone have any ideas what could be wrong?
Thanks