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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CmdButton to Open Form & Only Show Select Records 2

Status
Not open for further replies.

gyli84

MIS
Aug 6, 2001
67
GB
I am creating a helpdesk system and have a form called "Calls" showing all the calls/problems that have been received. I also have a "Manager's Console" form which shows certain information and has a text box called "UnassignedCalls" which shows the result of a query which counts the number of records in the Calls table that has the criteria "Completed" as 0 (False) and "Assigned User" as '' (Null). I want to create a command button that will open the Calls Form and ONLY display Unassigned Calls where "Completed" = 0 and "Assigned User" is Null. Can anyone help?

Thanks
 
Create a query with criteria for the fields set to the values you want to filter to, then put in the command button (assuming it is on the form used to display the records):

Code:
Me.RecordSource = "Query"
Me.Requery

where Query is the name of the query you have set up. This should change the display of the form to only the records you want. Have fun! :eek:)

Alex Middleton
 
My command button which I want to use to display only data with the criteria I specified above is in the "Manager's Console" Form, the form which I display the calls records in is called "Calls".
 
The command button will have to open the "Calls" form and only show the calls of matching the criteria. Does anyone know how to do this with VB On_Click of the command button?
 
Set up a query to filter the records then put the following code in the On_Click event:

Code:
docmd.OpenForm "FormName"
Forms![FormName].RecordSource = "QueryName"

This is the simplest way of doing this but there may be others.
Have fun! :eek:)

Alex Middleton
 
I don't know what Alex said cause his text is all garbled. Must be in a font I don't have.

Any ways, using the query to drive the criteria is one way. You can also specify a WHERE clause into the OpenForm method of the DoCmd object.

DoCmd.OpenForm "formname", , , "[Completed] = 0"
 
Well, the font was "Courier New" and was using the "code" tags that Tek-Tips allows you to use, so it is not that unusual a font. Anyway, I have reproduced here without the "code" tags:

Set up a query to filter the records then put the following code in the On_Click event:

docmd.OpenForm "FormName"
Forms![FormName].RecordSource = "QueryName"

This is the simplest way of doing this but there may be others.
Have fun! :eek:)

Alex Middleton
 
Continuing what Sameal suggested, which is the way I'd complete the task, this is how the statement would look with the other clause in it, which would be in the On_Click even for the command button.

DoCmd.OpenForm "formname", , , "[Completed] = 0 AND [Assigned User] = Null"
 
I've managed to solve the problem by using an OpenForm macro and specifying criteria in the WHERE box. Thanks for all the help everyone :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top