I need a report that will print two lines then leave a space then print another two lines. The file I'm using has a line number field that can run from 1 - 8 or 1 - 14 depending on the what the user chooses. The way the report needs to look is line 1 and 2 are together then a space then 3 and 4 go together and another space. Not to sure how to get this to work or if its possible. Any help will be greatly appreciated.
Besides Nico's approach, what you are requesting can be accomplished programmatically, although in a round-a-bout way: - Create an 'Unbound' Report.
- Create 2 'Unbound' Text Boxes on the Report (Text1, Text2) and position them on the Report exactly where you wish the values to appear.
- Set their Can Grow Properties to Yes.
- Execute the following code in the Report's Activate() Event.
- I assumed your Table Name is Table1.
- Private Sub Report_Activate()
-
Dim MyDB As DAO.Database
-
Dim rst As DAO.Recordset
-
Const conSPACE As String = vbCrLf & vbCrLf
-
Dim strBuild_1 As String
-
Dim strBuild_2 As String
-
-
Set MyDB = CurrentDb
-
Set rst = MyDB.OpenRecordset("Table1", dbOpenForwardOnly)
-
-
With rst
-
Do While Not .EOF
-
If ![Line Number] Mod 2 = 0 Then
-
strBuild_1 = strBuild_1 & ![Name] & conSPACE
-
strBuild_2 = strBuild_2 & ![Line Number] & conSPACE
-
Else
-
strBuild_1 = strBuild_1 & ![Name] & vbCrLf
-
strBuild_2 = strBuild_2 & ![Line Number] & vbCrLf
-
End If
-
.MoveNext
-
Loop
-
Me![Text1] = strBuild_1
-
Me![Text2] = strBuild_2
-
End With
-
-
rst.Close
-
Set rst = Nothing
-
End Sub
20 1975
report that will print two lines then leave a space then print another two lines.
Not exactly sure what you mean, CD Tom.
Hopefully I can expain it better.
I have a file that has Name and Line number the line number can be 1-8 or 1-14 depending on the users selection
I want a report to look like this
Name Line Number
Tom 1
Bill 2
(blank Line)
Sam 3
Georeg 4
(Blank Line)
Tony 5
Arthur 6
(Blank Line)
Jared 7
Matt 8
(blank Line)
William 1
Greg 2
etc.
I hope this makes some sense.
Thanks Tom
I would probably chose the "easy" way to manipulate the report's query like: -
SELECT Test.ID, Test.Field1, [ID] & "a" as Type
-
FROM Test
-
UNION
-
SELECT Test.ID,"", [ID] & "b"
-
FROM Test where [ID] Mod 2 = 0
-
order by 3
Thus an additional record is created for every "even" line.
I used the sample names in a table with an ID and got: -
ID Field1 Type
-
1 Tom 1 1a
-
2 Bill 2 2a
-
2 2b
-
3 Sam 3 3a
-
4 Georeg 4 4a
-
4 4b
-
5 Tony 5 5a
-
6 Arthur 6 6a
-
6 6b
-
7 Jared 7 7a
-
8 Matt 8 8a
-
8 8b
Nic;o)
Hello Nico5038, what effect does the ORDER BY 3 have?
Besides Nico's approach, what you are requesting can be accomplished programmatically, although in a round-a-bout way: - Create an 'Unbound' Report.
- Create 2 'Unbound' Text Boxes on the Report (Text1, Text2) and position them on the Report exactly where you wish the values to appear.
- Set their Can Grow Properties to Yes.
- Execute the following code in the Report's Activate() Event.
- I assumed your Table Name is Table1.
- Private Sub Report_Activate()
-
Dim MyDB As DAO.Database
-
Dim rst As DAO.Recordset
-
Const conSPACE As String = vbCrLf & vbCrLf
-
Dim strBuild_1 As String
-
Dim strBuild_2 As String
-
-
Set MyDB = CurrentDb
-
Set rst = MyDB.OpenRecordset("Table1", dbOpenForwardOnly)
-
-
With rst
-
Do While Not .EOF
-
If ![Line Number] Mod 2 = 0 Then
-
strBuild_1 = strBuild_1 & ![Name] & conSPACE
-
strBuild_2 = strBuild_2 & ![Line Number] & conSPACE
-
Else
-
strBuild_1 = strBuild_1 & ![Name] & vbCrLf
-
strBuild_2 = strBuild_2 & ![Line Number] & vbCrLf
-
End If
-
.MoveNext
-
Loop
-
Me![Text1] = strBuild_1
-
Me![Text2] = strBuild_2
-
End With
-
-
rst.Close
-
Set rst = Nothing
-
End Sub
Hi ADezii,
The ORDER BY clause allows to use the column (sequence) number instead of the column name.
So when the column is an algorithm I prefer to use the number instead of repeating the algorithm.
Nic;o)
Thanks you so much for the reply I'll try both and see which one works best for me. Thanks again.
Thanks Nico, you learn something new every day around here! (LOL)!
Adezii
I've been trying your approach but I only get one line to print. Am I missing something. I have the text1 and text2 fields in the detail section of the report, I also tried putting them in the page header section. Thanks for your help I hope I can get this to work.
I'll get a Demo DB together sometime today and make it available for you as an Attachment. Cold very possibly be that I misinterpreted something.
Hello CDTom, see if the Attachment works for you.
That worked I thought I had set the can grow to yes but I must have forgotten. Thanks for all your help.
NeoPa 32,556
Expert Mod 16PB @Nico5038
Trust you to know something like that Nico. I searched Help and it wasn't there. I also tested it (just to be sure. You know I expected it to work as you'd said it does.) and it works of course. This is a bit of a revelation for me. Thanks for the info.
Glad to have added something to your knowledge :-)
The query is however not 100 % as the sort will be alphabetical, thus the 1A will be followed by 10A, etc.
The correct query is -
SELECT Test.ID, Test.Field1, "a" as Type
-
FROM Test
-
UNION
-
SELECT Test.ID,"", "b"
-
FROM Test where [ID] Mod 2 = 0
-
order by 1, 3
Nic;o)
NeoPa 32,556
Expert Mod 16PB
Indeed. Clearly a tidier solution :)
I suppose there is no easy way of writing it in such a way as not to be dependent on the ID being in perfect sequence? I know ordinals in SQL are often sticky & I certainly see no obvious alternative.
@CD Tom
Hello CD Tom. Just for curiosity, have you tried Nico's approach, the final version of which is displayed in Post #15? I think that Nico's approach is more efficient, cleaner, and adaptable.
I haven't tried it Nico's approach, I guess I'm a little confused by it, not knowing for sure hope it works. I'll test it and see if it will become clear.
NeoPa 32,556
Expert Mod 16PB
In Nico's solution he uses an [ID] field to determine if the record is an even line or an odd one. This is fine if that matches your table. Otherwise, use whatever you have that displays this characteristic. From what you posted earlier I'm guessing you may have a [Line Number] field that may be appropriate. What is important for it to work is that you use a field that is even for each line before the extra (blank) line that you want added, but odd for all the ones after it. Does that make sense?
Yes it does make sense, I've been playing around with it and it does seem easier. Thanks for everything.,
Not only easier, but also faster :-)
VBA seems to slow things down in general at a 1:6 ratio or even worse...
So I prefer in general SQL (read query) solutions to have the database engine do the work.
Don't forget to use the second query I posted (With two sort fields), as that's working for every number of lines !
Nic;o)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tom |
last post by:
I have a report where one field tends to be rather lengthly and ends
up being several lines long while another field has several short
entries. The problem I have is that the first of the short...
|
by: shaqattack1992-newsgroups |
last post by:
I know this is kind of a weird question, but is there anyway to give a
subreport control of a main report?
I posted my situation earlier about having drawings print out after a
group. I have a...
|
by: salad |
last post by:
Hi Guys: I was stuck. I needed to send a report to a file. My
beautiful report(s) in Access were going to require loss of formatting
with RTFs, a PITA in WordMailMerge, sending it as a text...
|
by: Brad |
last post by:
Thanks for taking the time to read my question.
I have a table of data that has Date, Data and Category. I need to
show, in
a report, each Categories Data by Date. The Date has to be it's own...
|
by: lorirobn |
last post by:
Hi,
I have a report that works just fine.
Now I would like to add the capability to choose selection criteria to
limit what is displayed. I created several reports that do this, but
they used...
|
by: Wim Cossement |
last post by:
Hello,
I was wondering if there are a few good pages and/or examples on how to
process form data correctly for putting it in a MySQL DB.
Since I'm not used to using PHP a lot, I already found...
|
by: nadeaupn |
last post by:
Hi all,
Could somebody tell me how to set the content (text) of a special field in a not incorporated report (Crystal Report) using Visula Studio 2005 ?
I want to dynamically (at run time)...
|
by: kcdoell |
last post by:
I have been trying for the last several days to create a query that will give me all of the values I need to create a report.
Background:
The report is different than anything I have done but...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |