Error when using criteria to prompt for input

A

ant1983

Hi,

Ive got a query and have [Enter Date] in the criteria under one of my
fields. I get th ebelow error.

"The Microsoft Office Access database engine does not recognize '[Enter
Date]' as a valid field name or expression.
 
A

Allen Browne

In query design view, choose Parameters on the ribbon/toolbar.
Access will open the Parameters dialog. Enter a row like this:
[Enter Date] Date/Time

If that doesn't work, switch the query to SQL View, and post the SQL
statement. If this query draws from other queries, we need to know about
them too.
 
A

ant1983

Mmmmm.... Well i simplified it actually. my query is calld
qyTrainingDatesForClientWithCriteria and consists of several tables.
Basically i want to select a "Client Name" from a drop-down box on form
frmEmailScheduleToClientMenu which has a combo box cboClient. It should then
open the query so what i usually do is create such a form and then go to the
field in the query where i want to lookup info and build the following:

[Forms]![frmEmailScheduleToClientMenu]![numClient]

Usually works perfectly biut not this time. Heres the SQL:

SELECT tblTrainingSession.dateStartDate, tblTrainingSession.dateEndDate,
suptblCourse.txtCourse, suptblLevel.txtLevelAbbreviation,
tblClientContact.txtCompany, tblFacilitator.txtName, suptblCity.txtCity,
suptblSuburbs.txtSuburb, tblTrainingSession.txtVenue,
tblTrainingSession.numRoom, tblTrainingSession.numSeatsAvailable,
qryStatsBookingsBreakdown_Crosstab.FNB,
qryStatsBookingsBreakdown_Crosstab.FRCC,
qryStatsBookingsBreakdown_Crosstab.MOM,
qryStatsBookingsBreakdown_Crosstab.RMB,
qryStatsBookingsBreakdown_Crosstab.NON,
qryStatsBookingsBreakdown_Crosstab.[Total Of CountOfnumTrainingSessionID],
[Total Of CountOfnumTrainingSessionID]/[numSeatsAvailable] AS
PercentageBooked, qryStatsAttendanceBreakdown_Crosstab.FNB,
qryStatsAttendanceBreakdown_Crosstab.FRCC,
qryStatsAttendanceBreakdown_Crosstab.MOM,
qryStatsAttendanceBreakdown_Crosstab.RMB,
qryStatsAttendanceBreakdown_Crosstab.NON,
qryStatsAttendanceBreakdown_Crosstab.[Total Of CountOfnumAttended], [Total Of
CountOfnumAttended]/[Total Of CountOfnumTrainingSessionID] AS TurnoutRate,
[Total Of CountOfnumTrainingSessionID]/[numSeatsAvailable] AS Capacity,
[numSeatsAvailable]-[Total Of CountOfnumTrainingSessionID] AS SeatsRemaining,
tblTrainingSession.numLevel
FROM suptblSuburbs RIGHT JOIN (suptblCity RIGHT JOIN (tblFacilitator RIGHT
JOIN (tblClientContact RIGHT JOIN (suptblLevel RIGHT JOIN (suptblCourse RIGHT
JOIN (qryStatsAttendanceBreakdown_Crosstab RIGHT JOIN
(qryStatsBookingsBreakdown_Crosstab RIGHT JOIN tblTrainingSession ON
qryStatsBookingsBreakdown_Crosstab.numTrainingSessionID =
tblTrainingSession.autTrainingSessionID) ON
qryStatsAttendanceBreakdown_Crosstab.numTrainingSessionID =
tblTrainingSession.autTrainingSessionID) ON suptblCourse.autCourseID =
tblTrainingSession.numCourse) ON suptblLevel.autLevelID =
tblTrainingSession.numLevel) ON tblClientContact.autClientID =
tblTrainingSession.numClient) ON tblFacilitator.autFacilitatorID =
tblTrainingSession.numFacilitator) ON suptblCity.autCityID =
tblTrainingSession.numCity) ON suptblSuburbs.autSuburbID =
tblTrainingSession.numSuburb
WHERE
(((tblTrainingSession.numLevel)=[Forms]![frmEmailScheduleToClientMenu]![txtClient]) AND ((tblTrainingSession.blnCurrentTraining)=Yes))
ORDER BY tblTrainingSession.dateStartDate, tblTrainingSession.dateEndDate;


Allen Browne said:
In query design view, choose Parameters on the ribbon/toolbar.
Access will open the Parameters dialog. Enter a row like this:
[Enter Date] Date/Time

If that doesn't work, switch the query to SQL View, and post the SQL
statement. If this query draws from other queries, we need to know about
them too.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


ant1983 said:
Hi,

Ive got a query and have [Enter Date] in the criteria under one of my
fields. I get th ebelow error.

"The Microsoft Office Access database engine does not recognize '[Enter
Date]' as a valid field name or expression.

.
 
A

Allen Browne

You haven't declared the parameter yet. That's the first step.

Assuming that numLevel shows as a Number field when you open
tblTrainingSession in design view, you'll enter the parameter:
[Forms]![frmEmailScheduleToClientMenu]![txtClient] Long Integer

Also, test that the underlying query runs correctly. If it has a parameter
also, you *must* declare it if it's a crosstab. More info:
http://allenbrowne.com/ser-67.html#Param

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


ant1983 said:
Mmmmm.... Well i simplified it actually. my query is calld
qyTrainingDatesForClientWithCriteria and consists of several tables.
Basically i want to select a "Client Name" from a drop-down box on form
frmEmailScheduleToClientMenu which has a combo box cboClient. It should
then
open the query so what i usually do is create such a form and then go to
the
field in the query where i want to lookup info and build the following:

[Forms]![frmEmailScheduleToClientMenu]![numClient]

Usually works perfectly biut not this time. Heres the SQL:
SELECT tblTrainingSession.dateStartDate,
tblTrainingSession.dateEndDate,
suptblCourse.txtCourse,
suptblLevel.txtLevelAbbreviation,
tblClientContact.txtCompany,
tblFacilitator.txtName,
suptblCity.txtCity,
suptblSuburbs.txtSuburb,
tblTrainingSession.txtVenue,
tblTrainingSession.numRoom,
tblTrainingSession.numSeatsAvailable,
qryStatsBookingsBreakdown_Crosstab.FNB,
qryStatsBookingsBreakdown_Crosstab.FRCC,
qryStatsBookingsBreakdown_Crosstab.MOM,
qryStatsBookingsBreakdown_Crosstab.RMB,
qryStatsBookingsBreakdown_Crosstab.NON,
qryStatsBookingsBreakdown_Crosstab.[Total Of CountOfnumTrainingSessionID],
[Total Of CountOfnumTrainingSessionID]/[numSeatsAvailable]
AS PercentageBooked,
qryStatsAttendanceBreakdown_Crosstab.FNB,
qryStatsAttendanceBreakdown_Crosstab.FRCC,
qryStatsAttendanceBreakdown_Crosstab.MOM,
qryStatsAttendanceBreakdown_Crosstab.RMB,
qryStatsAttendanceBreakdown_Crosstab.NON,
qryStatsAttendanceBreakdown_Crosstab.[Total Of CountOfnumAttended],
[Total Of CountOfnumAttended]/[Total Of CountOfnumTrainingSessionID]
AS TurnoutRate,
[Total Of CountOfnumTrainingSessionID]/[numSeatsAvailable]
AS Capacity,
[numSeatsAvailable]-[Total Of CountOfnumTrainingSessionID]
AS SeatsRemaining,
tblTrainingSession.numLevel
FROM suptblSuburbs RIGHT JOIN (suptblCity RIGHT JOIN (tblFacilitator
RIGHT JOIN (tblClientContact RIGHT JOIN (suptblLevel
RIGHT JOIN (suptblCourse
RIGHT JOIN (qryStatsAttendanceBreakdown_Crosstab
RIGHT JOIN (qryStatsBookingsBreakdown_Crosstab
RIGHT JOIN tblTrainingSession
ON qryStatsBookingsBreakdown_Crosstab.numTrainingSessionID
= tblTrainingSession.autTrainingSessionID)
ON qryStatsAttendanceBreakdown_Crosstab.numTrainingSessionID
= tblTrainingSession.autTrainingSessionID)
ON suptblCourse.autCourseID = tblTrainingSession.numCourse)
ON suptblLevel.autLevelID = tblTrainingSession.numLevel)
ON tblClientContact.autClientID = tblTrainingSession.numClient)
ON tblFacilitator.autFacilitatorID = tblTrainingSession.numFacilitator)
ON suptblCity.autCityID = tblTrainingSession.numCity)
ON suptblSuburbs.autSuburbID = tblTrainingSession.numSuburb
WHERE (tblTrainingSession.numLevel =
[Forms]![frmEmailScheduleToClientMenu]![txtClient])
AND (tblTrainingSession.blnCurrentTraining)=Yes)
ORDER BY tblTrainingSession.dateStartDate,
tblTrainingSession.dateEndDate;
Allen Browne said:
In query design view, choose Parameters on the ribbon/toolbar.
Access will open the Parameters dialog. Enter a row like this:
[Enter Date] Date/Time

If that doesn't work, switch the query to SQL View, and post the SQL
statement. If this query draws from other queries, we need to know about
them too.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


ant1983 said:
Hi,

Ive got a query and have [Enter Date] in the criteria under one of my
fields. I get th ebelow error.

"The Microsoft Office Access database engine does not recognize '[Enter
Date]' as a valid field name or expression.

.
 
A

ant1983

WOW! That worked! Thanks a ton mate - u rock!

Allen Browne said:
You haven't declared the parameter yet. That's the first step.

Assuming that numLevel shows as a Number field when you open
tblTrainingSession in design view, you'll enter the parameter:
[Forms]![frmEmailScheduleToClientMenu]![txtClient] Long Integer

Also, test that the underlying query runs correctly. If it has a parameter
also, you *must* declare it if it's a crosstab. More info:
http://allenbrowne.com/ser-67.html#Param

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


ant1983 said:
Mmmmm.... Well i simplified it actually. my query is calld
qyTrainingDatesForClientWithCriteria and consists of several tables.
Basically i want to select a "Client Name" from a drop-down box on form
frmEmailScheduleToClientMenu which has a combo box cboClient. It should
then
open the query so what i usually do is create such a form and then go to
the
field in the query where i want to lookup info and build the following:

[Forms]![frmEmailScheduleToClientMenu]![numClient]

Usually works perfectly biut not this time. Heres the SQL:
SELECT tblTrainingSession.dateStartDate,
tblTrainingSession.dateEndDate,
suptblCourse.txtCourse,
suptblLevel.txtLevelAbbreviation,
tblClientContact.txtCompany,
tblFacilitator.txtName,
suptblCity.txtCity,
suptblSuburbs.txtSuburb,
tblTrainingSession.txtVenue,
tblTrainingSession.numRoom,
tblTrainingSession.numSeatsAvailable,
qryStatsBookingsBreakdown_Crosstab.FNB,
qryStatsBookingsBreakdown_Crosstab.FRCC,
qryStatsBookingsBreakdown_Crosstab.MOM,
qryStatsBookingsBreakdown_Crosstab.RMB,
qryStatsBookingsBreakdown_Crosstab.NON,
qryStatsBookingsBreakdown_Crosstab.[Total Of CountOfnumTrainingSessionID],
[Total Of CountOfnumTrainingSessionID]/[numSeatsAvailable]
AS PercentageBooked,
qryStatsAttendanceBreakdown_Crosstab.FNB,
qryStatsAttendanceBreakdown_Crosstab.FRCC,
qryStatsAttendanceBreakdown_Crosstab.MOM,
qryStatsAttendanceBreakdown_Crosstab.RMB,
qryStatsAttendanceBreakdown_Crosstab.NON,
qryStatsAttendanceBreakdown_Crosstab.[Total Of CountOfnumAttended],
[Total Of CountOfnumAttended]/[Total Of CountOfnumTrainingSessionID]
AS TurnoutRate,
[Total Of CountOfnumTrainingSessionID]/[numSeatsAvailable]
AS Capacity,
[numSeatsAvailable]-[Total Of CountOfnumTrainingSessionID]
AS SeatsRemaining,
tblTrainingSession.numLevel
FROM suptblSuburbs RIGHT JOIN (suptblCity RIGHT JOIN (tblFacilitator
RIGHT JOIN (tblClientContact RIGHT JOIN (suptblLevel
RIGHT JOIN (suptblCourse
RIGHT JOIN (qryStatsAttendanceBreakdown_Crosstab
RIGHT JOIN (qryStatsBookingsBreakdown_Crosstab
RIGHT JOIN tblTrainingSession
ON qryStatsBookingsBreakdown_Crosstab.numTrainingSessionID
= tblTrainingSession.autTrainingSessionID)
ON qryStatsAttendanceBreakdown_Crosstab.numTrainingSessionID
= tblTrainingSession.autTrainingSessionID)
ON suptblCourse.autCourseID = tblTrainingSession.numCourse)
ON suptblLevel.autLevelID = tblTrainingSession.numLevel)
ON tblClientContact.autClientID = tblTrainingSession.numClient)
ON tblFacilitator.autFacilitatorID = tblTrainingSession.numFacilitator)
ON suptblCity.autCityID = tblTrainingSession.numCity)
ON suptblSuburbs.autSuburbID = tblTrainingSession.numSuburb
WHERE (tblTrainingSession.numLevel =
[Forms]![frmEmailScheduleToClientMenu]![txtClient])
AND (tblTrainingSession.blnCurrentTraining)=Yes)
ORDER BY tblTrainingSession.dateStartDate,
tblTrainingSession.dateEndDate;
Allen Browne said:
In query design view, choose Parameters on the ribbon/toolbar.
Access will open the Parameters dialog. Enter a row like this:
[Enter Date] Date/Time

If that doesn't work, switch the query to SQL View, and post the SQL
statement. If this query draws from other queries, we need to know about
them too.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


Hi,

Ive got a query and have [Enter Date] in the criteria under one of my
fields. I get th ebelow error.

"The Microsoft Office Access database engine does not recognize '[Enter
Date]' as a valid field name or expression.

.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top