I wish the user to enter a date on a form, and click a command button. The command button then finds all records with that date in a certain column, and open the entries found in a certain form, ready to be edited.
Have the button open a form with a query based on the criterion set by what has been entered in the control on the form, e.g. a text box.
i.e. set up the form you want to display the records on as continuous forms or datasheet view and set up the underlying query with the fields you want to display. In the date field, set a criterion, e.g. if the original form is frmSelectDate and the control that the date is entered into is txtSelectDate, then the criterion in the date field would be something like
'Like [Forms]![frmSelectDate]![txtSelectDate]' (without the quotes).
This should display only those records dates matching the one entered. Alex Middleton
No, put this in the query underlying your second form, i.e. the query in the Record Source property of the second form.
To make it simpler, let's call them Form1 and Form2. On Form1 you will have, for example, a text box (Text1) where the selected date is entered. On Form2 the simplest method is to set it up as datasheet view then set the Record Source property to a new query. To do this, go into the property sheet for the form, click on the Record Source property, then click the little box with dots on it at the right of the dialog.
This will start a new query. Add the table you want the data to come from, then add the fields you want to display to the design grid. This will include the date field you are searching on the first form (Form1).
Under the date field in the design grid, add the code to the 'Criteria' line so that the query looks for records where the date matches the date selected on Form1. As I have changed names, the criteria would look like:
Code:
'Like [Forms]![Form1]![Text1]'.
Place a command button (Command1) on Form1 and add the following code to its OnClick event:
Docmd.OpenForm "Form2"
This will open Form2 and, if the query has been set up properly, all the records with the date matching the one in Text1 should be displayed, ready for editing. Alex Middleton
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.