Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing parameter to query from form

Status
Not open for further replies.

3239

Technical User
May 14, 2003
64
Hello everyone.

I am having a problem figuring out why my query is returning incorrect results. I have a form that accepts a date range from the user and passes the values from the text boxes on the form to the query. Sometimes the query returns the correct results but in some cases incorrect dates are returned. Is it some tricky thing Access have going on with dates being passed from a form to a query? Please help! My code is below.

Thanks

Code:
[b]SELECT[/b] Requisition.RequisitionNumber, PurchaseOrder.POID, Requisition.SupplierName, PurchaseOrder.Date, RequisitionLineItems.BudgetUnit, RequisitionLineItems.POChartOfAccount, RequisitionLineItems.UnitPrice, RequisitionLineItems.UnitsOrdered
[b]FROM[/b] (PurchaseOrder [b]INNER JOIN[/b] Requisition [b]ON[/b] PurchaseOrder.POID = Requisition.POID) [b]INNER JOIN[/b] RequisitionLineItems [b]ON[/b] Requisition.RequisitionNumber = RequisitionLineItems.RequisitionNumber [b]IN[/b] '\\Svr-fp-rh3\groups\Purchasing Tracking Database Systems\IS Procurement Test\IS Procurement Project Test_be.mdb'
[b]WHERE[/b] (((Requisition.SupplierName) Like "*" & [Forms]![POSearch]![Search3] & "*") [b]AND[/b] ((PurchaseOrder.Date) Is Not Null And (PurchaseOrder.Date) [b]Between[/b] [Forms]![POSearch]![Beginning Order Date] [b]And[/b] [Forms]![POSearch]![Ending Order Date]) [b]AND[/b] ((RequisitionLineItems.BudgetUnit) Like "*" & [Forms]![POSearch]![Search2] & "*") [b]AND[/b] ((RequisitionLineItems.POChartOfAccount) Like "*" & [Forms]![POSearch]![Search4] & "*"));
 
I found the problem. The Date field in my PurchaseOrder table data type was set to text instead of Date/Time. Now everything is working fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top