Print Statement

rbs

Board Regular
Joined
Oct 6, 2002
Messages
58
Hi Everyone,

I have a module that prints to a file, but I need it to append spaces at the end of the Supplier Id Field so that it is always 6 characters.

Can someone please help! :rolleyes:



Dim SSellInRecordType As String
Dim SSellInSupplierID As String
Dim SSellInTxnDate As String

Open SName For Output As #1 ' Open file for output.

Set Sdb1 = CurrentDb
Set Srecset1 = Sdb1.OpenRecordset("PURCHASES DAILY ALL") 'Open query that hasthe data
With Srecset1

Do Until .EOF 'do until end of file
SSellInRecordType = ![Record Type]
SSellInSupplierID = Format$(![Supplier ID], "######")
SSellInTxnDate = Format$(![Txn Date], "yyyymmdd")

Open SName For Append As #1 'will create a text file called
'exportdata on first loop
'and open the text file
'exportdata on subsequent loops
Print #1, SSellInRecordType & SSellInSupplierID & SSellInTxnDate
Close #1 'close the text file
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi,

Try this line:-

SSellInSupplierID = ![Supplier ID] & Space$(6 - Len(![Supplier ID]))
 
Upvote 0
Alternatively, this could help:

SSellInSupplierID = Left(![Supplier ID] & " ",6)
(that's 6 spaces in the quotes)...
...OR
SSellInSupplierID = Left(![Supplier ID] & Space$(6),6)

Denis
 
Upvote 0

Forum statistics

Threads
1,221,814
Messages
6,162,135
Members
451,744
Latest member
outis_

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top