PC Review


Reply
Thread Tools Rate Thread

displaying selected number of records in a form

 
 
=?Utf-8?B?bWFyaWthMTk4MQ==?=
Guest
Posts: n/a
 
      13th Feb 2006
Hello,

I've just set up a form in my application where the user selects several
conditions, presses a "GO"-style command button, and a new form appears with
the record matches is descending order in a subform. Problem is, in some
cases there are over 1,000 matches and I'd like to add a combo box where the
user can select the number of records he/she would like to view. I've
figured out that it's the Row Source Type = Value List and perhaps Row Source
= 10, 50, 100, ALL in the combo box - but I'm unsure of the code needed to
tie the combo box into the existing code behind the button that executes the
search, limiting the number of records displayed.

Also, I want to make sure that if someone selects "View 50" and there are
only 30 records, that it doesn't error out. . .

Many, many, many thanks for all your help. . . .

Marika

 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      13th Feb 2006
In the AfterUpdate event procedure or the combo, set the RecordSource of the
form. You can use TOP to limit the form to the number of records.

The code below tests the combo to see if it has a numeric value. If so, it
limits the number of records; if not, it shows them all.

The constant should contain whatever query you currently use for the form
without the SELECT word at the start.

Private Sub cboHowMany_AfterUpdate
Dim strPredicate As String
Const strcTail = " Table1.* FROM Table1;"

If Me.Dirty Then 'Save first.
Me.Dirty = False
End If

If IsNumeric(Me.cboHowMany) Then
strPredicate = " TOP " & Me.cboHowMany
End If

Me.RecordSource = "SELECT" & strPredicate & strcTail
End Sub

--
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.

"marika1981" <(E-Mail Removed)> wrote in message
news:F92A324E-3FCF-4B3B-AC46-(E-Mail Removed)...
> Hello,
>
> I've just set up a form in my application where the user selects several
> conditions, presses a "GO"-style command button, and a new form appears
> with
> the record matches is descending order in a subform. Problem is, in some
> cases there are over 1,000 matches and I'd like to add a combo box where
> the
> user can select the number of records he/she would like to view. I've
> figured out that it's the Row Source Type = Value List and perhaps Row
> Source
> = 10, 50, 100, ALL in the combo box - but I'm unsure of the code needed to
> tie the combo box into the existing code behind the button that executes
> the
> search, limiting the number of records displayed.
>
> Also, I want to make sure that if someone selects "View 50" and there are
> only 30 records, that it doesn't error out. . .
>
> Many, many, many thanks for all your help. . . .
>
> Marika



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Form Displaying Records that Meet the Criteria selected Bubu85238 Microsoft Access Forms 2 27th May 2008 04:40 PM
Code in Form to Change all Selected Records & Save Them Then Uncheck Selected Cory Microsoft Access VBA Modules 0 4th Dec 2007 04:18 PM
Form Displaying Wrong Number of Records JamesJ Microsoft Access Form Coding 4 21st Apr 2007 09:24 PM
Combo box isn't displaying selected records correctly. =?Utf-8?B?TWVsbGU=?= Microsoft Access Form Coding 1 6th Apr 2004 03:15 PM
Displaying multiple copies of selected records Craig Carboni Microsoft Access 3 29th Feb 2004 12:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:51 PM.