- Dim rs As DAO.Recordset
-
Dim sPath As String
-
Function ITAX()
-
sPath = "C:\temp\" ' just have the directory here
-
Set rs = CurrentDb.OpenRecordset("SAL")
-
Open sPath & "TAX.txt" For Output As #1
-
Do Until rs.EOF
-
EName = rs("name")
-
Edesg = rs("desg")
-
ecode = rs("ecode")
-
Print #1, ecode & Space(5) & EName & Space(5) & Edesg
-
rs.MoveNext
-
Loop
-
Close #1
-
rs.Close
-
Set rs = Nothing
-
End Function
this code displays same in below format which looks ugly.I want to display same in tabular format.such that name in one column designation in one columns in synchronization kindly advise how to print data in txt file in tabular format? - 0189 SMT BIMLA HEAD ASSTT
-
0190 SH PARTAP SINGH BIST HEAD ASSTT
-
018 SMT BIM HEAD ASSTT
-
019 SH TAP SINGH BIST HEAD ASSTT
4 2084 ADezii 8,834
Recognized Expert Expert
You can Output to Print Zones and pad the middle String Variable with a fixed number of Spaces that you define, as in: -
Dim rs As DAO.Recordset
-
Dim sPath As String
-
-
'User Defined CONSTANT
-
Const conLENGTH As Byte = 20
-
-
sPath = "C:\temp\" ' just have the directory here
-
Set rs = CurrentDb.OpenRecordset("SAL")
-
-
Open sPath & "TAX.txt" For Output As #1
-
-
Do Until rs.EOF
-
EName = rs("name")
-
Edesg = rs("desg")
-
ecode = rs("ecode")
-
Print #1, Format$(ecode, "0000"), EName & Space$(conLENGTH - Len(EName)), Edesg
-
rs.MoveNext
-
Loop
-
-
Close #1
-
-
rs.Close
-
Set rs = Nothing
-
OUTPUT: -
0189 SMT BIMLA HEAD ASSTT
-
0190 SH PARTAP SINGH BIST HEAD ASSTT
-
0018 SMT BIM HEAD ASSTT
-
0000 SH TAP SINGH BIST HEAD ASSTT
NeoPa 32,563
Recognized Expert Moderator MVP
While I have no doubt that ADezii's solution is perfectly correct and very useful, it may help to know that the Print# command, by default, tabulates your data for you anyway. You are simply bypassing this functionality by joining all your data into a single string before sending it.
If you use the comma (,) character to separate the values for each column it will tabulate automatically to the default column widths. If you want to tabulate to a specific column then this is also supported by using Tab(n) in your output stream, where n is the column number desired. You can also set the charpos for the next item to print and print a set number of spaces using Spc(n). Look in the help page for all this information.
Fundamentally though, Print# was designed to support these features.
ADezii 8,834
Recognized Expert Expert Print #1, ecode, EName, Edesg
will produce: -
189 SMT BIMLA HEAD ASSTT
-
190 SH PARTAP SINGH BIST HEAD ASSTT
-
18 SMT BIM HEAD ASSTT
-
0 SH TAP SINGH BIST HEAD ASSTT
Print #1, ecode; Tab(10); EName; Tab(35); Edesg
although a little more confusing, will produce: -
189 SMT BIMLA HEAD ASSTT
-
190 SH PARTAP SINGH BIST HEAD ASSTT
-
18 SMT BIM HEAD ASSTT
-
0 SH TAP SINGH BIST HEAD ASSTT
NeoPa 32,563
Recognized Expert Moderator MVP
Indeed. Clearly the second option is appropriate for this question, where the first isn't.
Although, with a limited length (<8 chars) number value at the start you could get away with : - Print #1, ecode, EName, Tab(35); Edesg
Only very variable fields need be handled by Tab(n).
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bob |
last post by:
Hi,
I am trying to use BULK INSERT with format file. All of our data has
few bytes of header in the data file which I would like to skip before
doing BULK INSERT.
Is it possible to write format file to skip these few bytes of
header before doing BULK INSERT? For example, I have a 1 GB data file
with 1000 byte header. Except for first...
|
by: Vanessa |
last post by:
I need to read/extract data from an Excel file using ASP. However, the Excel
file is not in regular tabular format; instead, it is actually a form.
Therefore, it contains many checkbox and merged cells with data.
I have followed this web page's instruction
(http://www.haneng.com/Forums_Post.asp?id=4099) to read data out, but
whenever the...
|
by: Eric |
last post by:
How to i create a form in tabular format without using wizard.
thanks,
|
by: lucky |
last post by:
Hi guys,
i want to write some data in tabular format in text file. i've data in
strings and i want to write like this in file
col1 col2 col3
d1 d1 d1
d2 d2 d2
d3 d3 d3
|
by: teju |
last post by:
Hello,
I have to display all the data from the database in tables in ASP. I am able to get the data but the problem is of displaying one to many relations.Like below Title1 has two records but how would i display in the table
Title1 heading1 heading 2 heading 3
x y x1 y1
a b a1 ...
| |
by: madhu542 |
last post by:
Hi,
I am trying to print the values of a file in the tabular format...
The contents of the file are :-
TILE 1:
Serial Number: 1
Model Number: 110A
Hardware Rev: 220A
|
by: sharan |
last post by:
Using the expat parser (http://expat.sourceforge.net/) i have to parse
the following xml file and print it on the screen in tabular
format. Want a c program on that in Linux environment.
xml file is:
<?xml version="1.0"?>
<users>
<user id="1">
<nameHari Oum </name>
<age24 </age>
<departmentProduct Development </department>
|
by: sharan |
last post by:
Using the expat parser (http://expat.sourceforge.net/) i have to parse
the following xml file and print it on the screen in tabular
format using C language. i am getting ouput serially but not in
tabular
xml file is:
<?xml version="1.0"?>
<users>
<user id="1">
<nameHari Oum </name>
<age24 </age>
|
by: jeet123 |
last post by:
hi,
i am new to c#. How can i make a form which displays data in a tabular format where the data is retrieved from the database (ms-access) and displayed in that from in table. No matter if the table data is editable or not but yes, the user must be able to print that data.
if we can add this feature of if the records displayed exceeds the...
|
by: zwamin |
last post by:
can someone let me know the html code for reading a text file with tab delimiter in a webpage in tabular format? number of rows in the text file is not known...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
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: 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: 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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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: 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 we have to send another system
| |
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...
| |