Limiting the number of selections in a List Box Control

Hi Folks,

I have a list box (multiselect = simple) that is dynamically populated by a 
query. I want the user to select only two items from the list and then i want 
to use these two items to run another quesry which will be the source data 
for a report.

How do i force the List Box to allow only two selections?

Regards,

John Dumay

0
Utf
12/31/2007 4:44:01 AM
access 16762 articles. 2 followers. Follow

1 Replies
1113 Views

Similar Articles

[PageSpeed] 40

On Sun, 30 Dec 2007 20:44:01 -0800, John Dumay wrote:

> Hi Folks,
> 
> I have a list box (multiselect = simple) that is dynamically populated by a 
> query. I want the user to select only two items from the list and then i want 
> to use these two items to run another quesry which will be the source data 
> for a report.
> 
> How do i force the List Box to allow only two selections?
> 
> Regards,
> 
> John Dumay

Code the List box BeforeUpdate event:

If Me.ListBoxName.ItemsSelected.Count > 2 Then
   MsgBox "Sorry, only 2 items can be selected."
   Cancel = True
End If

-- 
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
0
fredg
12/31/2007 5:20:44 AM
Reply:

Similar Artilces:

Displaying MS Excel Chart control in ASP.NET Application
Hi, We are working on an ASP.NET (VB.NET) application. In one of th screens of our application, we need to show a graph and for this we ar using MS Excel Graph control. We have the graph prepared in Excel. Th application would feed in certain values into certain cells of th excel file and the graph would be drawn by the graph control based o these cells. We need some help on how exactly to display the excel graph contro directly on the screen of ASP.NET application. Thanks for the help oursm -- oursmp ...

Credit Card Number on Receipt
Hi, I have replaced the default credit card tendering window with my own hook in. After the transaction is cleared it prints a receipt but it will not print the masked credit card number on the receipt that I have swiped on my application. HI, Make sure you are updating the correct fields data in your application, second check the TenderEntry table and verified that credit card number is saved there. you need to use the SQL Query tool from administrator program for this. If the above information is verified now check the receipt.xml file and find the credit card printing call procedur...

File Size Limit??
Hi, Can anyone tell me if there is a limit to the file size of an Excel 2000 document. We've got a guy here who has a 63Mb spreadsheet, and keeps wondering why he's getting "Out of memory" messages every time he opens it. I've put an extra 512Mb in his PC, but he's still getting lock-ups. He's convinced that there are no limits to the size of the file, but I'm pretty certain that there is... Anyone help? Thanks, Jon. The limit is memory. -- Don Guillett SalesAid Software donaldb@281.com "Jon" <anonymous@discussions.microsoft.com> ...

Total Number of Hours
I have a tracking sheet and I entered the total number of hours spent on a project and then when I want the sume the total is 6.65 instead of 7.05 for 7 hours and 5 minutes. How do I fix this? The way I entered the time is 0.35 for 35 minutes. Do I need to enter the times a different way? If you are in a place that use : as a time delimiter then you need to enter it like hh:mm 35 minutes should be entered as 0:35 -- Regards, Peo Sjoblom (No private emails please, for everyone's benefit keep the discussion in the newsgroup/forum) "celeste" <celeste@discussions.micros...

access2007 option group dotted line box around text
I have an access 2007 application with a form with a unbound option box with three option buttons and labels. When I select them sometimes the dotted box shows around 2 of the labels. The options have values 1, 2 and 3. Not sure why it is not just showing the dotted line box around the selected option? Any tips to fix it? Mark see my previous post for suggestions and resolution. I accidentally thought a deleted this one and it didn't post. Mark "Mark Andrews" <mandrewsNOSPAM@rptsoftware.com> wrote in message news:Okuv5ohaKHA.5608@TK2MSFTNGP05....

Limits
I am doing a fairly easy programme on excel. It is a catchment runoff, and evaporation calculator. But i would like to place a limit on a cell, and have that exess go into another column, is this possible? EG 75 rainfall, soil can hold only 10mm more. SO 10mm INFILTRATES, ie that cell should have a limit of the max soil moisutre, the other 65mm RUNOFF's and thats a different column. ANYBODY PLEASEEEEEEEEEE!!!! lol You need a Workbook_Change event macro for that. The code you would write in that macro should first check that the change occurred in a cell within the range you want. ...

adding numbers #2
Hello, I have a spreadsheet where I am storing hours. So 1h or 5h, etc... Is there a way I can select a bunch of cells. and add these numbers. Even though there is "h" in the cell? thanks SUM works just as well on time, just format the result cell as [h]:mm if it might exceed 24 hours. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "greg" <iuouh@ghfhg.com> wrote in message news:OvM5oBU1IHA.1240@TK2MSFTNGP02.phx.gbl... > Hello, > I have a spreadsheet where I am storing hours. > So 1h or 5h, etc... > I...

Adjusting One Side of a Box
Greetings, When in Design View and a text box, a label box, or a line are selected (just using those as examples), if I hold the "Windows Flag" key down pressing one of the cursor keys, whatever I've selected moves one dot in the direction I want. If I hold the Cntr key down while pressing the cursor key, it appears that I have 4x the sensitivity in moving (i.e., four presses of the cursor key moves the distance of one dot). Is there any way to do the same thing when needing to adjust just one side of a drawn box? Thanks. Ken -- Message posted via AccessMonster.com http:/...

Cell Selection?
I have a colum of numbers 198 0 0 198 2 What I need, is to be able to select 3. the 198's are not going to be used in the next part of my equation. That seems simple enough, however all the numbers could be usable (not 198) and I need to use just the first three. Any ideas? One interp / way, using non-array formulas Assuming source numbers in A1 down Put In B1: =IF(COUNT($C$1:C1)>3,"",C1) In C1: =IF(ISERROR(SMALL(D:D,ROW(A1))),"", INDEX(A:A,MATCH(SMALL(D:D,ROW(A1)),D:D,0))) In D1: =IF(A1="","",IF(A1=198,"",ROW())) Select B1:D...

Problem using Match on columns of numbers with leading zeroes formatted as text ???
In my test run, I was using a column of first names in workbook A to check and flag their presence in workbook B, The code given to me by Marcus here worked fine. No problem at all. .. When I switched to the real problem by replacing my columns of data with numbers with leading zeroes, the columns being already formatted as text, the program did not find Matches. .. In both workbooks columns of data, cells have an automatic Excel comment that says : "The number in this cell is formatted as text or preceded by an apostrophe". .. What am I missing here ? Is there a spe...

2008 R2 dpm 2007 setup: SIS-Limited not found?
I'm trying to run the command line to install the SIS component via ocsetup.exe SIS-Limited /quiet /norestart but it tells me it cant find this SIS-Limited component (on 2008 r2 x64).. Any ideas what i need to do to get past this? Thanks It turns out you just need to add the file services role in r2, dont need the manual command.. "markm75g" wrote: > I'm trying to run the command line to install the SIS component via > ocsetup.exe SIS-Limited /quiet /norestart > > but it tells me it cant find this SIS-Limited component (on 2008 r2 x64).. ...

Help! IF function is too limited
Hi! I've created a drop-down list of cities in a cell, under which there are two more cells to be filled out with the address and zip codes corresponding to each of the cities. How can I do this, knowing that the original list is a three-column list made of city-address-zip? -- Ringo ------------------------------------------------------------------------ Ringo's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=27502 View this thread: http://www.excelforum.com/showthread.php?threadid=470178 Use VLOOKUP into the original; list using the DV value =VLOOKUP(B...

sequential numbers
I simply want to sequentially number rows in a column. However, some of the rows do not contain any data so do not need to be numbered. So there is in fact a blank. It´s also possible that i´d want to add another row, and auto update the number sequence. You cannot drag the auto numbering facility across cells that you want to remain empty of course, because they will be numbered. With your data in column A,: Formula in B1 :1 In B2: =IF(A2="",B1,B1+1) Fill down. Format B2: Format>Conditional Formatting Cell Value is, Equal to, B1 (remove the $signs if you clic...

Q: Rules limit
There is a limit for Exchange Rules on a 32K-size (KB147298) Whether there is a way to change this limit for single users? For me already three users have addressed with such requests :- Thanks Alexander Kenin This is not a configurable limit. It's limited by the size of one RPC packet. "Kenin Alexander" <anonymous@discussions.microsoft.com> wrote in message news:80981636-20EB-4C64-B514-F9BCA635AFE7@microsoft.com... > There is a limit for Exchange Rules on a 32K-size (KB147298). > Whether there is a way to change this limit for single users? > For me already thre...

UnBound Control
can i change a property (eg. back color) for an unbounded control for a certain record while viewing the form as a continous form??????? Walid Bahgat wrote: >can i change a property (eg. back color) for an unbounded control for a >certain record while viewing the form as a continous form??????? Not using code. However, both those properties can be changed using Conditional Formatting in the Format menu. -- Marsh MVP [MS Access] Thanks for your reply but in this case i want to change the picture property of and image control "Walid Bahgat" wrote: > can i change a ...

GENERATE RANDOM NUMBERS BUT EXCLUDE A NUMBER IN THE SEQUENCE
I NEED TO GENERATE A RANDOM NUMBER BETWEEN 1-9 BUT NEED TO EXCLUDE WHATEVER IS IN THE CELL ABOVE IT. IF THE CELL ABOVE IT SAYS 8. I NEED TO GENERATE 1,2,3,4,5,6,7,OR 9. IM STUMPED? > I NEED TO GENERATE A RANDOM NUMBER BETWEEN 1-9 BUT NEED TO EXCLUDE > WHATEVER IS IN THE CELL ABOVE IT. IF THE CELL ABOVE IT SAYS 8. I NEED > TO GENERATE 1,2,3,4,5,6,7,OR 9. IM STUMPED? On way: In A2:A100, put =RANDBETWEEN(1,8) In B1, put =RANDBETWEEN(1,9) In B2, put =A2+(A2>=B1) and copy down to B100 Use the values in column B. I might of explained it wrong. I want to use random(1,9) but...

Macro to insert rows based on user selection
I have a macro that allows a user to insert one or more rows based on a user input box. This allows me to control which formulae get copied into the new cells. The macro works fine UNLESS the user scrolls around the screen before making their selection. How can I resolve this? This is the key part of the script. Thanks, Mike Sub Row_Insertion() ' ' This macro inserts a user-specified number of rows ' and ensures that the relevant formulae are copied ' into the new rows. Range("I3").Select ' Makes I3 the active cell and Set rn...

Compare two lists of data to find new entries
I currently run a daily report from a CRM database to monitor my sales teams activities with customers. Each activity has a 'unique' reference. My aim is to compare the report (which is in excel) from one day with the new report to show the new 'activities'. In simple terms I want to say if activity 'x' is in the new list the show the information from that row on a new worksheet so I can see at a glance the new activities. How about an alternative? Insert a new column near that unique reference (say column B is inserted and column A is the unique reference). T...

Limiting Internet Email for Users
I want to stop users from sending Internet email from my Exchange 2000 server. I use it for a company wide mail server. Can anyone help me stop Internet Email. This might help: http://www.msexchange.org/tutorials/MF009.html -- Mark Fugatt Exchange MVP http://www.exchangetrainer.com http://www.msexchange.org "Bob" <anonymous@discussions.microsoft.com> wrote in message news:14B7AF2C-73E3-4601-84F9-3F7B95043B72@microsoft.com... > I want to stop users from sending Internet email from my Exchange 2000 server. I use it for a company wide mail server. Can anyone help me stop...

Finding the number of records in a query
Hi there! I want to restrict my users from running a query if there are records in a second query. The second query has 2 parameters based on forms, [Forms]![frmInvBusNums]![InventoryNum] and [Forms]![frmInvBusNums]![BusUnit] The code I'm trying to run, which is totally wrong looks something like this: Dim db As DAO.Database ' Dim rst As DAO.Recordset ' ' Set db = CurrentDb ' ' ' set rst=db.QueryDefs "Discrepancy_Report" ' If rst.RecordCount > 0 Then ' MsgBox "There are conflicts" ' Exit Sub ' ...

Hide a text box
On sheet 3 of my workbook I have created a button (button 62) and a text box (textbox 63). What I want to do is use the button to toggle the text box on and off. By that I want to be able to show the box or hide the box. I have tried to copy code from the MS Visual Basic Help but it did not work, basically because I have no idea what I am doing. Can someone lease help? Orf Bartrop Under my Excel - 2000 I don't think you can hide a text box But I hope Im wrong it would be a good idea Steve On Wed, 09 Aug 2006 05:45:55 +0100, Orf Bartrop <orf@southcom.com.au> = wrote: > On...

Control box question
I have a form that opens when you run a query. (example: employee last name) Then when I want to look up another name I want to do it from the form instead of closing the form. So I added a control box to the form to run the query again. The problem is that it opens up a new form, so if I do multiple searches I will have a lot of open forms. So the the question is: Can I set up the control box to run the query and open it in the same form or at least close the last form when it opens a new one? If so how is this done? Thanks Eric How about placing an unbound combo box at t...

Convert Number to Word in Receipt
Hi all, How can i convert Transaction amount to Words in receipt XML file. Is any function like CurrencyToString there..? thanks in advance, CP.Dinesh VbCurrencyWords, this is one of the values of attribute 'type' of the SET element. Rob "C.P.Dinesh" wrote: > Hi all, > > How can i convert Transaction amount to Words in receipt XML file. > Is any function like CurrencyToString there..? > > thanks in advance, > > CP.Dinesh > > Thanks Rob. "Rob" wrote: > VbCurrencyWords, this is one of the values of attribute 'ty...

Limit outgoing mail limit before send
Hi all Is there any method to avoid to send mail if the mail size is over a preset limit? If I set it in Exchange, the mail will first send to Exchange server and check the size. Any method to check the size before send to server? I got this problem since the connection speed is slow, not like local 100m network. Exchange server and the client Outlook XP PC is far away, connect with a 64K line only. Thanks ...

list numbers in a block of cells
Is there a way to list the values in a block of cells. 400 600 800 350 200 625 250 222 125 9958 226 123 Like: 400 600 800 350 200 625 250 222 125 9958 226 123 Assume source data in A1:C4 Put in say, E1: =OFFSET($A$1,INT((ROWS($1:1)-1)/3),MOD(ROWS($1:1)-1,3)) Copy E1 down to E12 -- Max Singapore http://savefile.com/projects/236895 xdemechanik --- "Jeff Klein" <jklein@nospam> wrote in message news:%23PyCLFqPIHA.5140@TK2MSFTNGP05.phx.gbl... > Is there a way to list the values in a block of cells. > > 400 600 800 > 350 200 6...