首页 > 解决方案 > Trouble with using a form to search multiple dates in Access and return a query

问题描述

So I've got a customer that has the need to search multiple dates on an appointment. I've created a form that has inputs set up to capture one of the dates and returns a query based on the dates entered.

This is the table design:

TableDesign

This is what the form looks like

FormDesign

Submitting the form runs this query

    SELECT PersonType.Category, Person.FirstName, Person.LastName, Person.DOB, Pet.Name, Pet.Microchip, Appointment.Cost, Appointment.AppointmentDate, Appointment.[Respite In], Appointment.[Respite Out], Appointment.[Rehome In], Appointment.[Rehome Out], Appointment.[In Date], Appointment.[Out Date], Appointment.[Service Location], Appointment.Note
FROM ((PersonType 
INNER JOIN Person ON PersonType.PersonTypeId = Person.PersonTypeID) INNER JOIN Pet ON Person.PersonID = Pet.PersonID) 
INNER JOIN Appointment ON (Pet.ID = Appointment.PetID) AND (Person.PersonID = Appointment.PersonID)
WHERE (((Appointment.AppointmentDate)>=[Forms]![Search Appointment Dates]![AppointmentDate] And (Appointment.AppointmentDate)<=[Forms]![Search Appointment Dates]![AppointmentEnd]) OR ((Appointment.[Respite In]) = [Forms]![Search Appointment Dates]![RespiteIn]) OR ((Appointment.[Respite Out]) = [Forms]![Search Appointment Dates]![RespiteOut]) OR ((Appointment.[Rehome In]) = [Forms]![Search Appointment Dates]![RehomeIn]) OR ((Appointment.[Rehome Out]) = [Forms]![Search Appointment Dates]![RehomeOut]) OR ((Appointment.[In Date]) = [Forms]![Search Appointment Dates]![InDate]) OR ((Appointment.[Out Date]) = [Forms]![Search Appointment Dates]![OutDate]));

Running the query from the form results in a 3270 error and attempting to open the query itself brings up the following error. To this point this has been more frustrating than I anticipated and I'm not sure why this is happening or how to get this to work successfully.

Error

标签: ms-access

解决方案


推荐阅读