G
golfdog via AccessMonster.com
Looking to extract records from a query line by line ouputted to a single
text file in a prescribed format. The formatted lines can be one of 6
different versions depending upon the value in the field Cmd. I am able to
loop out data of one criteria and it would appear that some form of IF
statement or Case would be necessary to grab the rest of the data, but I have
not had any luck getting this to work. I even create 6 individual queries
that can export to the set text file, but each overwrites the previous. Am
about at wits end on this, with a whole lot of time trying all I know....
Private Sub Command148_Click()
Dim rs As DAO.Recordset
Dim strfile As String
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.CreateTextFile("C:\Changes\DataScript.csv", True)
strfile = "C:\Changes\DataScript.csv"
Do While Not rs.EOF
strOut = "DATASUBMIT " & rs!Cmd & " " & rs!InvNo & " " & " " & Chr(34) & rs!
InvDescr & Chr(34) _ & " " & Chr(34) & Chr(34) & " " & "1" & " " & "Z01" & "
" & rs!InvPri
f.WriteLine strOut
rs.MoveNext
Loop
The other outputs needed:
strOut = "DATASUBMIT " & rs!Cmd & " " & rs!InvNo
strOut = "DATASUBMIT " & rs!Cmd & " " & rs!InvNo & " " & " " & Chr(34) & rs!
InvDescr & Chr(34) _ & " " & Chr(34) & Chr(34) & " " & "1" & " " & "Z01" & "
" & rs!InvPri
strOut = "DATASUBMIT " & rs!Cmd & " " & rs!InvNo & " " & rs!ExisInvNm & " " &
rs!NewInvNm
strOut = "DATASUBMIT " & rs!Cmd & " " & rs!Grp & " " & rs!Rgn & " " & rs!Lvl
strOut = "DATASUBMIT " & rs!Cmd & " " & rs!Grp & " " & rs!Rgn & " " & rs!
OldCont & " " & rs!NewCont
Thanks.
text file in a prescribed format. The formatted lines can be one of 6
different versions depending upon the value in the field Cmd. I am able to
loop out data of one criteria and it would appear that some form of IF
statement or Case would be necessary to grab the rest of the data, but I have
not had any luck getting this to work. I even create 6 individual queries
that can export to the set text file, but each overwrites the previous. Am
about at wits end on this, with a whole lot of time trying all I know....
Private Sub Command148_Click()
Dim rs As DAO.Recordset
Dim strfile As String
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.CreateTextFile("C:\Changes\DataScript.csv", True)
strfile = "C:\Changes\DataScript.csv"
Do While Not rs.EOF
strOut = "DATASUBMIT " & rs!Cmd & " " & rs!InvNo & " " & " " & Chr(34) & rs!
InvDescr & Chr(34) _ & " " & Chr(34) & Chr(34) & " " & "1" & " " & "Z01" & "
" & rs!InvPri
f.WriteLine strOut
rs.MoveNext
Loop
The other outputs needed:
strOut = "DATASUBMIT " & rs!Cmd & " " & rs!InvNo
strOut = "DATASUBMIT " & rs!Cmd & " " & rs!InvNo & " " & " " & Chr(34) & rs!
InvDescr & Chr(34) _ & " " & Chr(34) & Chr(34) & " " & "1" & " " & "Z01" & "
" & rs!InvPri
strOut = "DATASUBMIT " & rs!Cmd & " " & rs!InvNo & " " & rs!ExisInvNm & " " &
rs!NewInvNm
strOut = "DATASUBMIT " & rs!Cmd & " " & rs!Grp & " " & rs!Rgn & " " & rs!Lvl
strOut = "DATASUBMIT " & rs!Cmd & " " & rs!Grp & " " & rs!Rgn & " " & rs!
OldCont & " " & rs!NewCont
Thanks.