V
Vandenee
Hi,
I have following problem: I want to write files (.upd), the name of
the file can have a leading zero (glasnummer).
When I run this code I get the files but the leading zero's deleted.
How can I get a filename with the leading zero (for example 01234.upd)
This is the code I'm using at this moment.
Thanks you for your reply
Sub test()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("tblGlasgegevens Query")
If rst.RecordCount = 0 Then
MsgBox "Sorry, no records found.", vbExclamation
GoTo end_process
End If
ctr = 1
rst.MoveFirst
Do Until rst.EOF
fn = Format(rst.Fields("glasnummer")) & ".upd"
Open "H:\Gegevens\Michiel\glasgegevens\ACCESS FILES\UPD files
Vimec\" & fn For Output As #1
Print #1, "artikel=" & rst.Fields("glasnummer")
Print #1, "d1=" & rst.Fields("maximum")
Print #1, "d2=" & rst.Fields("mondranddiameter")
Print #1, "d3=" & rst.Fields("triggerdiameter d2")
Print #1, "h1=" & rst.Fields("producthoogte")
Print #1, "h2=" & rst.Fields("bakhoogte")
Print #1, "h3=" & rst.Fields("ondergrens las h3")
Print #1, "h4=" & rst.Fields("bovengrens las h4")
Print #1, "h5=" & rst.Fields("ondergrens been h5")
Print #1, "h6=" & rst.Fields("bovengrens been h6")
Close #1
rst.MoveNext
ctr = ctr + 1
Loop
end_process:
rst.Close
Set rst = Nothing
Set db = Nothing
End Sub
I have following problem: I want to write files (.upd), the name of
the file can have a leading zero (glasnummer).
When I run this code I get the files but the leading zero's deleted.
How can I get a filename with the leading zero (for example 01234.upd)
This is the code I'm using at this moment.
Thanks you for your reply
Sub test()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("tblGlasgegevens Query")
If rst.RecordCount = 0 Then
MsgBox "Sorry, no records found.", vbExclamation
GoTo end_process
End If
ctr = 1
rst.MoveFirst
Do Until rst.EOF
fn = Format(rst.Fields("glasnummer")) & ".upd"
Open "H:\Gegevens\Michiel\glasgegevens\ACCESS FILES\UPD files
Vimec\" & fn For Output As #1
Print #1, "artikel=" & rst.Fields("glasnummer")
Print #1, "d1=" & rst.Fields("maximum")
Print #1, "d2=" & rst.Fields("mondranddiameter")
Print #1, "d3=" & rst.Fields("triggerdiameter d2")
Print #1, "h1=" & rst.Fields("producthoogte")
Print #1, "h2=" & rst.Fields("bakhoogte")
Print #1, "h3=" & rst.Fields("ondergrens las h3")
Print #1, "h4=" & rst.Fields("bovengrens las h4")
Print #1, "h5=" & rst.Fields("ondergrens been h5")
Print #1, "h6=" & rst.Fields("bovengrens been h6")
Close #1
rst.MoveNext
ctr = ctr + 1
Loop
end_process:
rst.Close
Set rst = Nothing
Set db = Nothing
End Sub