gulati
10-23-2001, 11:25 PM
i wnat to do a query based on a form where the user inputs the criteria for the query..how do i do that???Eg..Suppose if the users puts the date of some kind that has to be the condition in the query..
|
View Full Version : query from a form gulati 10-23-2001, 11:25 PM i wnat to do a query based on a form where the user inputs the criteria for the query..how do i do that???Eg..Suppose if the users puts the date of some kind that has to be the condition in the query.. DJN 10-24-2001, 02:49 AM Create an unbound form. Add two unbound text boxes, txtBeginDate and txtEndDate. Add a command button and behind the button add this code. On Error GoTo Err_cmdButtonName_Click Dim stDocName As String stDocName = "YourQueryName" DoCmd.OpenQuery stDocName, acNormal, acEdit Exit_cmdBetweenDates_Click: Exit Sub Err_cmdButtonName_Click: MsgBox Err.Description Resume Exit_cmdButonName_Click Create a query with the fields you want. In the date field enter the following criteria. Between [forms]![FormName]![txtBeginDate] And [forms]![FormName]![txtEndDate] If you don't want an additional form to open , then just place two text boxes on the form the user has open and refer to that form name in the criteria of the query. Hope that helps. David |