Hi,
I have a form that opens a report. The form allows the user to pick a particular warehouse or supplier and an order to sort by. Here is the code for it: -
Private Sub cmdOK_Click()
-
-
Dim strSQL As String
-
If Me.cboSort1 <> "" Then
-
strSQL = strSQL & Me.cboSort1
-
If Me.Chk1 = True Then
-
strSQL = strSQL & " DESC"
-
End If
-
strSQL = strSQL & ", "
-
DoCmd.OpenReport "rptTopSuppliers", acViewPreview
-
DoCmd.Maximize
-
If strSQL <> "" Then
-
strSQL = Left(strSQL, (Len(strSQL) - 2))
-
Reports![rptTopSuppliers].OrderBy = strSQL
-
Reports![rptTopSuppliers].OrderByOn = False
-
Else
-
Reports![rptTopSuppliers].OrderByOn = True
-
End If
-
-
Else
-
MsgBox "Please choose a field to sort by.", vbOKOnly, "Missing Information"
-
End If
-
End Sub
-
In this, I want to include a list box that tells the report to only return top 5, 10, 25 or all records (or if possible, have the user enter how many records and if left blank return all records). I need help incorporating this. I tried it briefly, but I am too unfamiliar with VB. I need a good place to start I think, because I'm baffled at the moment.
1 1938
Hi,
I have a form that opens a report. The form allows the user to pick a particular warehouse or supplier and an order to sort by. Here is the code for it: -
Private Sub cmdOK_Click()
-
-
Dim strSQL As String
-
If Me.cboSort1 <> "" Then
-
strSQL = strSQL & Me.cboSort1
-
If Me.Chk1 = True Then
-
strSQL = strSQL & " DESC"
-
End If
-
strSQL = strSQL & ", "
-
DoCmd.OpenReport "rptTopSuppliers", acViewPreview
-
DoCmd.Maximize
-
If strSQL <> "" Then
-
strSQL = Left(strSQL, (Len(strSQL) - 2))
-
Reports![rptTopSuppliers].OrderBy = strSQL
-
Reports![rptTopSuppliers].OrderByOn = False
-
Else
-
Reports![rptTopSuppliers].OrderByOn = True
-
End If
-
-
Else
-
MsgBox "Please choose a field to sort by.", vbOKOnly, "Missing Information"
-
End If
-
End Sub
-
In this, I want to include a list box that tells the report to only return top 5, 10, 25 or all records (or if possible, have the user enter how many records and if left blank return all records). I need help incorporating this. I tried it briefly, but I am too unfamiliar with VB. I need a good place to start I think, because I'm baffled at the moment.
You're going to have to split up your starting strSQL this way: -
If Nz(Me.mylistbox, "") <> "" Then
-
strSQL = "select top" & Me.mylistbox & " FROM yourtable "
-
End If
-
Remember that combo boxes are 0 based..so the first column is going to be the value used, unless you select the column number me.mylistbox.co lumn(1)
J
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Matik |
last post by:
Hello everyone,
Small and (I think) very simple quesiton;-) which makes me creazy.
Let's say I have two tables listed below:
T1
====
IDX
====
1
|
by: Joseph Del Medico |
last post by:
I'm trying to use a query whose SQL view is shown below to get a
recordset of all first quarter records from a table for a year that is
in the textbox of a form, so I can sum up the totals for the first
quarter for every person and display them on the form. The query works
fine when I preview it in the query builder, but when I try to open a...
|
by: allyn44 |
last post by:
HI--I have 2 tables
Cut: cut ID, HistNumb, Block, date: Cut Id is the primary key, the other 3 fileds are indexed to be
unique
Slides: Cutid SlideID, and various other fields: there can be multiple slide records per CutID.
This table is a subdatashet of the Cut table--so the CutId is stored in it
I have a form based on a query between...
|
by: Eskil |
last post by:
Hi
I have a form that supplies my query with information on two different
variables. The form uses a lookup to display a list of 5 different
customer types and 5 different types of meetings/activities in two
different combo boxes.
Now, the values of form variables go into a query upon which a report
is generated. By using those two...
|
by: M.L. Abram |
last post by:
Hello all,
I do not know if this question is regarding table design, queries, or
programming. Below, I have given a table design using Access 2003.
Fields 'Product' and 'Color' are primary keys and 'Active'
is a Boolean data type. What I am trying to accomplish is having only
one record selected active out of the 'Product' field for each...
| |
by: areef.islam |
last post by:
Hi, I am kinda new to javascript and I am having this problem with
selecting multiple options from a select tag. Hope someone can help me
out here.
here is my code
///////////////////////////////////////////////////////////////////////////////////////
<form action="whatever.php" method="post">
<select name="zip_code"...
|
by: greg |
last post by:
Hi,
I don't think my message posted correctly so here it is.
Is there any way to access the individual values of a form text box?
I want to iterate through all of the rows and access the values of a
text box in my form.
thanks.
|
by: Jeffrey Davis |
last post by:
I'm hoping that someone here can give me some assistance with a
database I'm trying to set up. My skills in Access are fairly basic,
and I'm trying to skill up, but some of the stuff is a little opaque.
I'm trying to put some data I've got on paper into Access. Recently,
I
got together with some other people marketing organic produce and...
|
by: rousseaud |
last post by:
Hello,
I need some help/advise about how to tackle an Access problem. Right now, it's kind of a big idea and I would really appreciate any input about how to do it properly.
I essentially want to create a form that queries various records. I then want a user to be able to select various and specific records from the results of the query to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |