Multiple fields using to search

Hi,

Something i've been batteling for weeks with and theres probably such a 
simple answer to it and i just cant see it:

Riiiight, i have this form (lets call it frmClientSearch)

On this form i have a 2 list box thinghys; One called lstEmployee which is 
populated with Employee names and the other lstCity which is populated with 
City Names.

Then i have a command button (cmdSearch) which, once click and values 
selected in both the lst boxes, should return only the values that are equal 
to both the lst boxes in a new form called frmSearchResult.

(Hope i make sense)

So... I know how to do this if i have only one list box. (The wizard does 
the work) but i dont know how to do it with multiple "criteria" (for lack of 
a better word) boxes.

PLEASE HELP!!!

Fanks!!!



0
Utf
7/10/2007 7:20:01 PM
access.forms 6864 articles. 2 followers. Follow

3 Replies
994 Views

Similar Articles

[PageSpeed] 53

On Tue, 10 Jul 2007 12:20:01 -0700, ant1983
<ant1983@discussions.microsoft.com> wrote:

>Hi,
>
>Something i've been batteling for weeks with and theres probably such a 
>simple answer to it and i just cant see it:
>
>Riiiight, i have this form (lets call it frmClientSearch)
>
>On this form i have a 2 list box thinghys; One called lstEmployee which is 
>populated with Employee names and the other lstCity which is populated with 
>City Names.

Does your table contain the actual employee and city NAMES? or does it contain
a foreign key to the Employee and/or City table?

>Then i have a command button (cmdSearch) which, once click and values 
>selected in both the lst boxes, should return only the values that are equal 
>to both the lst boxes in a new form called frmSearchResult.

Care to post the code? We can't see it from here.

>(Hope i make sense)
>
>So... I know how to do this if i have only one list box. (The wizard does 
>the work) but i dont know how to do it with multiple "criteria" (for lack of 
>a better word) boxes.
>
>PLEASE HELP!!!

Please help us to help you. We can't see your database, don't know the
structure of your table, don't know your fieldnames, and don't know the code
you're now using. 

             John W. Vinson [MVP]
0
John
7/10/2007 8:00:27 PM
Hey John!

Sorry bout being so vague.  Thing is i've tried to do this before and had no 
luck so it drove me insane and im in the process of building another db so i 
thought i should ask before attempting hence there was no code to paste.

I've recreated the problem now but before i paste the code here's a little 
context:

1 - I am a HUGE beginner so please excuse my ignorance :)
2 - I dont really write code.  i simple run the wizards and as a last resort 
change code where necessary but find that i dont really have to do this much 
as the wizards erally cover most of what i want...

Riiiight, now that my confessions are out of the way. Here's the deal.

My tables are simple tables:

tblCity
tblEmployee
tblJob

The tblJob is the main table and it looks up the values of tblEmployee and 
tblCity.

Then i have a form called frmClientSearch and on this form i have two list 
boxes lstEmployee and lstCity which fetches its contents from their 
respective tables as above.

Riiiight, so the command button (cmdSearch) on frmClientSearch was created 
to open frmSearchResult with the selected values in the frmClientSearch.  
This command button was simply created with the 'Open Form' wizard HOWEVER in 
one of the steps in the wizard it asks you if you want to open the form and 
display ALL results are only one corresponding with a value on the 
existing/open form.  I selected the latter and linked EmployeeName to 
EmployeeName in their respective forms.

The problem is you cant select multiple values and link them to more than 
one value on the form to be opened so thats where the problem lies. *gulp* (I 
think)

Riiight, bearing in mind the wizrd did the work, here is the code:

Private Sub cmdSearch_Click()
On Error GoTo Err_cmdSearch_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmSearchResult"
    
    stLinkCriteria = "[JobEmployee]=" & Me![lstEmployee]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdSearch_Click:
    Exit Sub

Err_cmdSearch_Click:
    MsgBox Err.Description
    Resume Exit_cmdSearch_Click
    
End Sub

Damn!  Hope i answered all of your questions (i think i did) and again sorry 
for being vague!

Many thanks!!!

Wayne


"John W. Vinson" wrote:

> On Tue, 10 Jul 2007 12:20:01 -0700, ant1983
> <ant1983@discussions.microsoft.com> wrote:
> 
> >Hi,
> >
> >Something i've been batteling for weeks with and theres probably such a 
> >simple answer to it and i just cant see it:
> >
> >Riiiight, i have this form (lets call it frmClientSearch)
> >
> >On this form i have a 2 list box thinghys; One called lstEmployee which is 
> >populated with Employee names and the other lstCity which is populated with 
> >City Names.
> 
> Does your table contain the actual employee and city NAMES? or does it contain
> a foreign key to the Employee and/or City table?
> 
> >Then i have a command button (cmdSearch) which, once click and values 
> >selected in both the lst boxes, should return only the values that are equal 
> >to both the lst boxes in a new form called frmSearchResult.
> 
> Care to post the code? We can't see it from here.
> 
> >(Hope i make sense)
> >
> >So... I know how to do this if i have only one list box. (The wizard does 
> >the work) but i dont know how to do it with multiple "criteria" (for lack of 
> >a better word) boxes.
> >
> >PLEASE HELP!!!
> 
> Please help us to help you. We can't see your database, don't know the
> structure of your table, don't know your fieldnames, and don't know the code
> you're now using. 
> 
>              John W. Vinson [MVP]
> 
0
Utf
7/11/2007 9:04:03 AM
On Wed, 11 Jul 2007 02:04:03 -0700, ant1983
<ant1983@discussions.microsoft.com> wrote:

>Hey John!
>
>Sorry bout being so vague.  Thing is i've tried to do this before and had no 
>luck so it drove me insane and im in the process of building another db so i 
>thought i should ask before attempting hence there was no code to paste.
>
>I've recreated the problem now but before i paste the code here's a little 
>context:
>
>1 - I am a HUGE beginner so please excuse my ignorance :)
>2 - I dont really write code.  i simple run the wizards and as a last resort 
>change code where necessary but find that i dont really have to do this much 
>as the wizards erally cover most of what i want...
>
>Riiiight, now that my confessions are out of the way. Here's the deal.
>
>My tables are simple tables:
>
>tblCity
>tblEmployee
>tblJob
>
>The tblJob is the main table and it looks up the values of tblEmployee and 
>tblCity.

That's part of the problem. Microsoft did a VERY BAD JOB when they provided
the Lookup field capability. See http://www.mvps.org/access/lookupfields.htm
for a critique.

The problem is that your Table APPEARS to contain the city name and the
employee name.... but it doesn't. What it contains, and what you have to
search for, is a concealed numeric ID number.

>Then i have a form called frmClientSearch and on this form i have two list 
>boxes lstEmployee and lstCity which fetches its contents from their 
>respective tables as above.

This should be OK, if the Bound Column property of these listboxes is the
numeric ID.

>Riiiight, so the command button (cmdSearch) on frmClientSearch was created 
>to open frmSearchResult with the selected values in the frmClientSearch.  
>This command button was simply created with the 'Open Form' wizard HOWEVER in 
>one of the steps in the wizard it asks you if you want to open the form and 
>display ALL results are only one corresponding with a value on the 
>existing/open form.  I selected the latter and linked EmployeeName to 
>EmployeeName in their respective forms.
>
>The problem is you cant select multiple values and link them to more than 
>one value on the form to be opened so thats where the problem lies. *gulp* (I 
>think)

well, multiselect opens a whole different can of worms, and the form wizard is
NOT capable of dealing with it!

>Damn!  Hope i answered all of your questions (i think i did) and again sorry 
>for being vague!

This was much clearer, thank you. What you'll need will be some considerably
more elaborate code looping through the listbox's ItemsSelected collection to
construct a query containing all of the selected employee ID's. Air code,
untested:

Private Sub cmdSearch_Click()
On Error GoTo Err_cmdSearch_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim iPos As Integer

    stDocName = "frmSearchResult"
    
    stLinkCriteria = "[JobEmployee]  IN (" 
    With Me![lstEmployee]
    For iPos = 0 to .ItemsSelected.Count
        stLinkCriteria = stLinkCriteria & .ItemsSelected(iPos) & ", "
    Next iPos
    stLinkCriteria = Left(stLinkCriteria, Len(stLinkCriteria) - 2) & ")"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdSearch_Click:
    Exit Sub

Err_cmdSearch_Click:
    MsgBox Err.Description
    Resume Exit_cmdSearch_Click
    
End Sub


             John W. Vinson [MVP]
0
John
7/11/2007 11:33:47 PM
Reply:

Similar Artilces:

Removing multiple hyperlinks
I've got data copied into my spreadsheet that includes hyperlinks. Ther are thousands of these in a column. I can remove individually by right-clicking and selecting Hyperlink an Remove. I can then arrow down and do a control Y, cell by cell, What I want to do is highlight the column and be able tp remove th hyperlinks all at once. I've exhausted myself peering through knowlegebases and groups, bu cannot find any way to make this work. Thanks for any input you can provide -- Message posted from http://www.ExcelForum.com Hi one way: Use the following macro to remove hyperlinks...

Create a list with multiple criteria
I have a data base with 1,000's of addresses w/zipcodes (Sheet 1 columns A to E, E being zipcodes). After setting a base address I get all of the zipcodes within a given radius (in this case 70 zipcodes), listed in Sheet 2, Column A. Next, I use COUNTIF (in column B) to find how many addresses are in each zipcode, in this example there are 46 addresses within the 70 zipcodes. What I want to do is create a list in sheet three that will list each with the data from Sheet 1 columns A to E). Any help would be appreciated. Ronbo ...

Charting multiple multiples
Hopefully I can explain this in a way that will be understood. Data: Place A Place B Place C FWD Back FWD BACK FWD Back Org_1 1 2 3 2 1 3 Org_2 2 5 4 6 1 4 I would like to place the data so that FWD and Back data is stacked on top of each other in different colors, and placed in one row on a 3-D chart as Org-1 and a second row as Org_2. Any ideas? Thanks. If you arrange your data like this: Back FWD Org_1 Place A 2 1 Place B 2 3 Place C 3 1 Org_2 Place A 5 2 ...

Multiple Hyperlinks In Same Shape Doesn't Work
Can anyone tell me how I can get multiple hyperlinks in the same shape to work? I have no problem inserting the hyperlinks, but they all point to only one. I scoured these posts, and found this (http://groups.google.com/groups?q=hyperlink+group:microsoft.public.visio.*&hl=en&lr=&ie=UTF-8&oe=UTF-8&group=microsoft.public.visio.*&selm=3eea6467%241%40news.microsoft.com&rnum=2), which doesn't appear to work. Thanks in advance-- RAD Um, which version of Visio are you using? As far as I know, at least Visio 2002 and Visio 2003 support multiple hyperlinks. Can't...

Multiple Profiles, multiple accounts, multiple machine configuring?
Is there a vb or related method of adding *both* profiles *and* email accounts to multiple users logins from the administrator account? I have a network which is a workgroup (NOT a domain), in which there are about 15 users that are replicated on each of 5 machines. I'd like to be able to add all 15 Mail Profiles, and all 15 email accounts to each of the 15 logins on these 5 machines--obviously with as little work as possible. The mail is all retrieved from the same Exchange Server, but these machines *cannot* be added to a domain (don't ask!). I'd hate to have to log into ...

distributing data into multiple cells
hii i have to prepare an exel sheet of some 2000 products..i have to copy d data from the net and then prepare the sheet,with 4 different columns for 4 diff types of entries..now when i copy data nad paste is as text.it all goes in a single cell in a row .how can i distribute the data l into multiple cells????????? -- jaspreet ------------------------------------------------------------------------ jaspreet's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=23821 View this thread: http://www.excelforum.com/showthread.php?threadid=374772 can you show some samp...

Single click selects multiple cells
When clicking on a single cell multiple cells are selected. The one time solution for this is to zoom in or out. This is problematic as 60% seems to be the zoom that works most of the time but at this zoom level the cell contents do not display. The time lost and the frustration that builds is killing my productivity and office attitude. Please give all of us a permanet fix. -- Thanks Mike ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" butt...

How can I determine what DC Project server is using for AD sync?
I am looking to determine what Domain Controller (hostname) that Project Server is connecting to when it tries to Sync with AD. My Sunc job is failing and the AD team wants to know what DC I am connecting to... I have no idea, how to get this info... Thanks for any help!! Mossguy: How many DCs on your network? Project Server is looking for domain global groups, and not a specific domain controller, so it talks to whichever DC responds to the request, and this shouldn't matter to your AD team. If they need to determine this information, you can ask the network team t...

Order of Events when using the Control Box Close Button
I would like to intercept the built in messages that are generated by Access about required data when a user clicks on the Close Button. The Close Button is enabled by setting the Control Box and Close Button form properties to "Yes". Does anyone know what the order of events is when using the Close Button? Thanks much! Answered in later post. Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia "accesswanabe" <accesswanabe@discussions.microsoft.com> wrote in message news:E44530CC-48AE-4134-A896-BFC71F032F68@microsoft.com... >I...

Is there a way to sort multiple columns with a tab or something?
I have a 4 column spreadsheet. I want to be able to click the heading for each of the columns to hav them sort by that column if clicked. How do I do that -- Message posted from http://www.ExcelForum.com Hi why not used the soprt icon for this. Note: This could screw up your sorting if Excel does not recognize your database columns correctly -- Regards Frank Kabel Frankfurt, Germany > I have a 4 column spreadsheet. > > I want to be able to click the heading for each of the columns to have > them sort by that column if clicked. How do I do that? > > > --- > Mess...

Using Off-line files to synchronise pst file
This is a multi-part message in MIME format. ------=_NextPart_000_0022_01C52659.2A201E60 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Can I use Off-line files (XP Pro SP2) to synchronise Outlook 2003 pst = file between laptop and desktop? --=20 Interim Systems and Management Accounting Gordon Burgess-Parker=20 Director www.gbpcomputing.co.uk ------=_NextPart_000_0022_01C52659.2A201E60 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4....

GPS Coordinates Field
Good day, Seems like default addresses have a longitude and latitude field within MSCRM 1.2. Unfortunately a float data type has been configured which does not allow for modification. The format of a coordinate would be something like Of course we could enter our own custom field but with MS Map Point being a future consideration we would like leverage from this by using captured data in the correct format... Depending on accuracy required we could have values such as Redmond being 47-40'27.32 The only allowable format wraps the numerical value entered into something in the fashion o...

Sending to multiple addresses
How do I send an email to multiple addresses having only the recipient see their own email address? Michelle wrote: > How do I send an email to multiple addresses having only > the recipient see their own email address? Put the addresses into the BCC: field. Note that many e-mail programs will decide such mails are spam though. >-----Original Message----- >How do I send an email to multiple addresses having only >the recipient see their own email address? >. Open your new email and go to tools, select recipient, when your address book opens select (highlight) the a...

Some basic reporting fields
1. Daily Sales by register, the register number field was "filter value invalid" why is this when i am putting in the right register number? 2. How can i pull a daily sales but when i try to input a date in the date field, it is not giving me that particular date? It is saying that a numeric field is required. I put in it as 10/21/2005 and this is the format, so i do not understand why this is happening? 3. In the detail sales report, every item is listed even if that item is sold 10 times, it shows up 10 times, how can i get a summary of the detail sales. The summary sales rep...

Using ISAPI with MFC
Hi All: I have been developing ISAPI extensions using straight Win32 API. In other newsgroups I have been told that there will be problems if I try to develop ISAPI extensions using MFC especially if you use ISAPI extension wizard. I have been using VC 6.0 on a Windows 2003 Server with IIS 6.0. When using just Win32 code, the IE browser and Web pages generated by the Extension DLL's seem to work fine. When I generate the same function using MFC, which takes a lot less code, the browser and Web pages don't seem to work correctly. The Web browser does not display Web page on the first t...

multiple selection
How can I select multiple records into a list box? I want that for append identical records (for select records) in another table. Many thanks Florin Use a subform instead of a list box. In a subform bound to a related table, you can append as many rows as applicable. It is possible (but not simple) to use an unbound multi-select list box that is populated in the Current event of the form, and executes Append, Delete, and Update query statements based on the ItemsSelected if they are changed. You will also have to find a way to respond to the user "undoing" changes. -- Al...

Exchange 2000 Distribution Lists
Hello We are running an Exchange 2000 environment in Exchange Native Mode and Windows Mixed Mode. We just converted from Exchange 5.5 Is there any way to configure multiple people to be owners or editors of the distribution lists? This was possible in 5.5, but we cannot find a means of accomplishing this in 2000 Any help would be appreciated Thank yo Jason "Jason P.S." <jason.pruden-shebaylo@investorsgroup.com> wrote: >We are running an Exchange 2000 environment in Exchange Native Mode and Windows Mixed Mode. We just converted from Exchange 5.5. > >Is there any w...

Need to have a dropdown list containing multiple rows
I am setting up an form and need to create a dropdown list that will contain 8 sets of data. Each set needs to contain 3 rows of data (name, street address & city/state/zip. The goal is to allow the user to click onto the cell, see the dropdown and select which address set to use. This would then place the data into three rows suitable for mailing. I have never attempted anything like this and am in need of assistance. Thank you. --- Message posted from http://www.ExcelForum.com/ Pat What you ask is easily done using Data Validation drop-down list and a few Vlookups but........Ex...

OWA and using Smart Card Login
I would like a brief checklist on how to go about using/implementing SCL with OWA. Our environment: Windows 2003 Server Exchange 2003 3rd party certificates are used All users currently use SCL to login at work. Thanks ! -- Jhonnyg This may help: Supporting Outlook Web Access with the S/MIME Control in Your PKI (Exchange Server Message Security Guide) http://www.microsoft.com/technet/prodtechnol/exchange/guides/E2k3MsgSecGuide/42b8152a-681d-43db-a3d6-dd52900519fa.mspx -- Bharat Suneja MVP - Exchange www.zenprise.com NEW blog location: www.exchangepedia.com/blog --------------------------...

Combine multiple tables into one
I took over a database in which the last person created a new table for everyday worth of data (ie. Feb-21-08 is named 022108). There are over 100 tables in the single database with the same columns and table attributes, I would like to combine all of these tables into one where I have a Date_Key field in place of the table name. I figured out how to query the table names using the following: SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND (Left$([Name],4) <> "Msys") AND (MSysObjects.Type)=1 ORDER BY MSysObjects.Name; Now I j...

Multiple domains #6
Hi, Having done some research I have found that it is possible to send and receive email from multiple domains with Exchange 2003. I have a few questions that I would like cleared up if anyone can help. 1. Is it really as simple as configuring a recipient policy for the new domain and then changing the mail record for that domain to point to the proper IP address? 2. If I set up a new account in AD, and need this account to be associated with the second email domain, will the default SMTP email be for the first domain? If so, can I just edit this directly? 3. If I set the default SMTP add...

How can I use my Access list to email selective groups?
How can I use an Access List to email selective groups without having to go to my Outlook Address Book? ...

Form Field/Function problem
I have 4 fields on my main form. The 4th field is controlled by a function. The function automatically adds the scores from the other 3 fields and puts the total score in the 4th field. All of that works great. The problem I'm having is that I need the color on that 4th field to change if any of the other 3 fields are below 60 points. I've tried adding some code that would change the color, under the 'After Update' and 'After Change' property field and I can't get it to work at all. Thank you in advance for any help! Place a procedure like this air co...

Cannot create exchange Mailbox using Active Directory
We are running WIndows server 2003, We have installed exchange 2003 as a new server over it. I have already made some users as recepient in the Active directory, but still (after 3 hrs) I am unable to see thier mailboxes in exchange system manager. I had used Active directory to create new users. We are also running SBS 2003 on it. You won't see mailboxes listed in Exchange System Manager until a) The mailbox has been logged into for the first time or b) The mailbox receives its first message -- Neil Hobson Exchange MVP For Exchange news, links, and tips, check: http://www.m...

forwarding mail to multiple external addresses
I have a user on our Exchange Server 2003 that wants his email to be forwarded to 2 different external email addresses and not have the original mail stored in his exchange mailbox at all. I can set this up to froward to only one external email address by creating a contact in Active Directory with an external email address and then forwarding to that contact. However, it won't allow me to forward to multiple contacts. Please help as this seems like a pretty common request from several users. I'm not sure, as I haven't tested it before, but you might be able to create a ...