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 1932
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.column(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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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,...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
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...
| |