Kun skrive de første 3 karakter
HejJeg bruger nedenstående til at smide noget data fra access til excel. Men når den skal skrive scanning.stregkode så vil jeg kun have de første 3 karakter med. Feltet består fx af 114p3 og jeg vil så kun have 114 skrevet i excelarket. Nogen der kan hjælpe?
<%
Dim objConn 'Holds the Database Connection Object
Set objConn = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\stafet.mdb"
Function CreateExcel(Title,tblname)
Dim Rs,Fso,Act,fname
Fname = "Udtrak\Udtrak_hold_tid.xls"
Set rs = Server.CreateObject("ADODB.Recordset")
Set FSO = Createobject("scripting.filesystemobject")
Set act = Fso.CreateTextfile(server.mappath(Fname),true)
rs.Open Tblname, objconn, 3, 3
If Not Rs.EOF and not Rs.BOF Then
act.WriteLine "<html xmlns:x=""urn:schemas-microsoft-com:office:excel"">"
act.WriteLine "<head>"
act.WriteLine "<!--[if gte mso 9]><xml>"
act.WriteLine "<x:ExcelWorkbook>"
act.WriteLine "<x:ExcelWorksheets>"
act.WriteLine "<x:ExcelWorksheet>"
act.WriteLine "<x:Name>"& title &"</x:Name>"
act.WriteLine "<x:WorksheetOptions>"
act.WriteLine "<x:Print>"
act.WriteLine "<x:ValidPrinterInfo/>"
act.WriteLine "</x:Print>"
act.WriteLine "</x:WorksheetOptions>"
act.WriteLine "</x:ExcelWorksheet>"
act.WriteLine "</x:ExcelWorksheets>"
act.WriteLine "</x:ExcelWorkbook>"
act.WriteLine "</xml>"
act.WriteLine "<![endif]--> "
act.WriteLine "</head>"
act.WriteLine "<body>"
Act.Writeline "<table border=1>"
Act.Writeline "<Tr>"
Act.Writeline "<Td><b>Nr</b></td>"
For X = 0 to Rs.Fields.count - 1
Act.Writeline "<Td><b>" & Rs.Fields.Item(x).Name & "</b></td>"
Next
Act.Writeline "</Tr>"
While not Rs.Eof
antal = antal + 1
Act.Writeline "<Tr>"
Act.Writeline "<Td>"& antal &"</td>"
For X = 0 To Rs.Fields.Count - 1
Act.Writeline "<Td>" & Rs.Fields.Item(X).Value & "</td>"
Next
Act.Writeline "</Tr>"
Rs.Movenext
Wend
Act.Writeline "</Table>"
act.writeline "<tr></tr>"
act.writeline "<tr>BEC Stafet 2010</tr>"
act.WriteLine "</body>"
act.WriteLine "</html>"
End if
Act.close
Rs.close
%>
<html>
<body style="background-color: #ECF9FF">
Dit excel udtræk kan hentes hér: <a href="<%=fname%>" target="_blank"> Udtræk </a>
<br>
<br>
</body>
</html>
<%
End function
call CreateExcel("Holdenes tider","SELECT scanning.tid, hold.navn, scanning.stregkode, hold.virksomhed FROM scanning INNER JOIN Hold ON (scanning.holdnr = hold.Holdnr) WHERE RIGHT(stregkode, 2) = 'p3' order by tid asc")
'Reset server objects
Set rs = Nothing
Set objConn = Nothing
%>
