I think that subject line needs a little explanation.
I've inherited (i.e. I didn't create it but I need to use it) an Access module that essentially creates a text file that my customers can import into their accounting systems as an electronic (EDI) invoice.
It looks like this, when opened in a text-viewer:
The reason I'm posting here today is that we've just added a customer whose system demands a line at the end of the invoice which indicates the total number of lines in the invoice. This will vary, depending on the number of items in the order (there's a loop in the code which writes specific info like price and productcode for each line-item in the order).
So . . . I need some way to count the number of ts.WriteLines that have been executed in any given invoice, and then include another ts.WriteLine statement which puts that number in the invoice :banghead: Actually, that number less two because it doesn't need to count the UNA and UNB lines.
I've been googling for hours, but no real luck. All of the counting functions I've turned up all seem to deal with tallying up the total number of records in a table or counting occurrences of specific characters in strings, etc; nothing that seem to apply to this particular situation.
I have this kind of vague idea that I could count the number of apostrophes that have been written (although trying to get Access to recognize that I'm not using them as Comment marks seems like a nightmare), but I'm at a dead end as to how to accomplish that.
Any help you can offer would be much appreciated!
I've inherited (i.e. I didn't create it but I need to use it) an Access module that essentially creates a text file that my customers can import into their accounting systems as an electronic (EDI) invoice.
It looks like this, when opened in a text-viewer:
UNA:+.? '
UNB+UNOC:3+6319807:31B+63:91+150826:1043+i22727'
UNH++INVOIC'
BGM+380+22727+43'
DTM+137:20150826:102'
LIN+000001'
IMD+L+050+::
retty Slick'
QTY+47:1'
MOA+203:250.00'
RFF+LI:.o15175911'
LIN+000002'
IMD+L+050+:::Fargo?: Season One'
QTY+47:1'
MOA+203:39.99'
RFF+LI:.o15175959'
UNS+S'
CNT+2:2'
MOA+86:296.65'
ALC+C++++TX'
MOA+8:0'
UNT+56+00000000055181'
UNZ:15000000022732'
The 3-letter designators at the start of each line alert the accounting system as to the meaning of the rest of the line. The apostrophe serves to designate the end of the line. The lines are created by ts.WriteLine statements in the module's code [ ts.WriteLine "UNA:+.? '", ts.WriteLine "UNB+UNOC:3+6319807:31B+" & rsOrders("CustomerID") . . ., etc. ].UNB+UNOC:3+6319807:31B+63:91+150826:1043+i22727'
UNH++INVOIC'
BGM+380+22727+43'
DTM+137:20150826:102'
LIN+000001'
IMD+L+050+::

QTY+47:1'
MOA+203:250.00'
RFF+LI:.o15175911'
LIN+000002'
IMD+L+050+:::Fargo?: Season One'
QTY+47:1'
MOA+203:39.99'
RFF+LI:.o15175959'
UNS+S'
CNT+2:2'
MOA+86:296.65'
ALC+C++++TX'
MOA+8:0'
UNT+56+00000000055181'
UNZ:15000000022732'
The reason I'm posting here today is that we've just added a customer whose system demands a line at the end of the invoice which indicates the total number of lines in the invoice. This will vary, depending on the number of items in the order (there's a loop in the code which writes specific info like price and productcode for each line-item in the order).
Code:
LinNum = 0
If rsDetails.RecordCount > 0 Then
Do While Not rsDetails.EOF
LinNum = LinNum + 1
ts.WriteLine "LIN+" & Format(LinNum, "000000") & "'"
ts.WriteLine "IMD+L+050+:::" + EscapeInput(Left(rsDetails("PRODUCT"), 35)) & "'"
ts.WriteLine "QTY+47:" & rsDetails("QuantityShipped") & "'"
ts.WriteLine "MOA+203:" & Format(((rsDetails("QuantityShipped")) * (rsDetails("PricePerUnit"))), "0.00") & "'"
If (IsNull(rsDetails("Option02")) Or (rsDetails("Option02") = "")) Then
ts.WriteLine "RFF+LI:.o" & rsDetails("OrderNumber") & rsDetails("ItemNumber") & "'"
Else
ts.WriteLine "RFF+LI:.o" & Left$(rsDetails("Option02"), 33) & "'"
End If
rsDetails.MoveNext
Loop
I've been googling for hours, but no real luck. All of the counting functions I've turned up all seem to deal with tallying up the total number of records in a table or counting occurrences of specific characters in strings, etc; nothing that seem to apply to this particular situation.
I have this kind of vague idea that I could count the number of apostrophes that have been written (although trying to get Access to recognize that I'm not using them as Comment marks seems like a nightmare), but I'm at a dead end as to how to accomplish that.
Any help you can offer would be much appreciated!