在循环输出txt文件时,为什么只能输出一个txt文档?
大侠请帮忙看看下面的语句:
Do while not rsAdviceHeaderRecord.EOF
OutputFileName =advicenum &replace(CStr(Date()), "/ ", " ")+ " "+replace(CStr(Time), ": ", " ")+ ".Txt "
If fso.FileExists(DTSGlobalVariables( "OutputPath ").Value & OutputFileName) Then
fso.DeleteFile DTSGlobalVariables( "OutputPath ").Value & OutputFileName, True
End If
fso.CreateTextFile DTSGlobalVariables( "OutputPath ").Value & OutputFileName, True
Set fname = fso.GetFile(DTSGlobalVariables( "OutputPath ").Value & OutputFileName)
DTSGlobalVariables( "FaxFileName ").Value = fname
Set tstream = fname.OpenAsTextStream(2, -2)
tstream.Write "{{begin}} " & VBCrLf
tstream.Write "{{fax " &faxnum & " )) " &VBCrLf
tstream.Write "{{fax to name " &faxtoname & " )) "& VBCrLf
tstream.Write "{{company Symcor}} " &VBCrLf
tstream.Write "{{attach "& " <PATH AND FILENAME FOR PDF> }} " & VBCrLf
tstream.Write "{{end}} " & VBCrLf
tstream.Close
rsAdviceHeaderRecord.MoveNext
Loop
本来数据表里有两条纪录,也就是说我输出的文件应该有两个,可是现在只能得到一个?
奇怪的是如果我在:
OutputFileName =advicenum &replace(CStr(Date()), "/ ", " ")+ " "+replace(CStr(Time), ": ", " ")+ ".Txt "
后面加上:Msgbox OutputFileName
就可以得到两个输出的txt,并且结果是正确的。。。。。
请帮忙看看。。
-------Thanks a lot---------------
一个不懂VB的小妞!!!大家莫要笑话~~~~~~~~~~
[解决办法]
是不是数据库更新太慢了
[解决办法]
把你写msgbox的地方换成doevents试试看。你的代码没有问题,看上去貌似系统关闭和打开文件的问题。
[解决办法]
可能程序执行的太快,两次文件名是同一个