Re: Query based on form open
- From: "Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx>
- Date: Thu, 2 Nov 2006 10:47:59 +0800
Set the RecordSource of the form, so it uses the criteria you want.
For example, if the form is bound to tblCustomer, and you want to show only
the customers where the SalesRepID field is 99:
Private Sub Form_Open(Cancel As Integer)
Dim strSql As String
strSql = "SELECT * FROM tblCustomer WHERE SalesRepID = 99;"
Me.RecordSource = strSql
End If
Now as the rep browses through the records, they can see only those assigned
to this rep.
If you are trying to create a flexible search so they can find a customer
quickly, see:
Find as you type - Filter forms with each keystroke
at:
http://allenbrowne.com/AppFindAsUType.html
or:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Spencer" <Spencer@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C3F2A023-CA43-4C5E-84E4-6757646931FC@xxxxxxxxxxxxxxxx
I have a customer database that sales people use to track their customers.
On
opening the sales rep can search for the customer by account no, phone
number, contact name, or company name which then opens the main form,
frmCustomers. For security reasons I don't want the sales rep to have
access
to the main table only to a query (so they can't copy the customer list).
How
do I have the query look up the customer based on the form that is open
and
the criteria that is selected? I hope this makes sense.
.
- Prev by Date: Re: create query from unrelated tables
- Next by Date: Re: Schema
- Previous by thread: Schema
- Next by thread: Make-Table AND Union Query
- Index(es):
Relevant Pages
|