Grax Posted May 23, 2008 Share Posted May 23, 2008 I've written a program that collects data via user input and dumps that data to an .mdb database. However I'd like to be able to print this information as well. Can someone point me in the right direction? I haven't' found much if any help on this topic. Thanks, Andrew Link to comment Share on other sites More sharing options...
weaponx Posted May 23, 2008 Share Posted May 23, 2008 Well there are infinite possibilities here. You could generate an html file along with your database that would be formatted nicely. Link to comment Share on other sites More sharing options...
Grax Posted May 23, 2008 Author Share Posted May 23, 2008 (edited) Well there are infinite possibilities here. You could generate an html file along with your database that would be formatted nicely.You're suggesting that I create an html file, open it with IE and print it? Hmm interesting idea. Had not thought of doing it this way, was thinking more of directly printing to the printer.Is there way to print the html file without having to open it in IE first?Andrew Edited May 23, 2008 by Grax Link to comment Share on other sites More sharing options...
weaponx Posted May 23, 2008 Share Posted May 23, 2008 (edited) This will generate the html: expandcollapse popup$OutFile = "test.html" ;TEST DATA Dim $Data[4][3] $Data[0][0] = "ID" $Data[0][1] = "First Name" $Data[0][2] = "Last Name" $Data[1][0] = 1 $Data[1][1] = "John" $Data[1][2] = "Smith" $Data[2][0] = 2 $Data[2][1] = "George" $Data[2][2] = "Bush" $Data[3][0] = 3 $Data[3][1] = "Megan" $Data[3][2] = "Fox" ;HTML $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' & @CRLF $html &= '<html xmlns="http://www.w3.org/1999/xhtml">'& @CRLF $html &= '<head>'& @CRLF $html &= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'& @CRLF $html &= '<title>Untitled Document</title>'& @CRLF ;CSS - START $html &= '<style type="text/css">'& @CRLF $html &= '<!--'& @CRLF $html &= '.RowColor1 {'& @CRLF $html &= ' background-color: #CCCCCC;'& @CRLF $html &= '}'& @CRLF $html &= '.RowColor2 {'& @CRLF $html &= ' background-color: #F4F4F4;'& @CRLF $html &= '}'& @CRLF $html &= 'body {'& @CRLF $html &= ' font-family: Arial, Helvetica, sans-serif;'& @CRLF $html &= '}'& @CRLF $html &= 'th {'& @CRLF $html &= ' color: #FFFFFF;'& @CRLF $html &= ' background-color: #000033;'& @CRLF $html &= '}'& @CRLF $html &= '-->'& @CRLF $html &= '</style>'& @CRLF ;CSS - END $html &= '</head>'& @CRLF $html &= ''& @CRLF $html &= '<body>'& @CRLF $html &= '<table width="100%" border="0" cellpadding="3" cellspacing="1">'& @CRLF ;Set starting row color from CSS $RowColor = "RowColor1" ;Loop through all rows For $Y = 0 to Ubound($Data,1)-1 $html &= ' <tr class="' & $RowColor & '">'& @CRLF ;Loop through all columns For $X = 0 to Ubound($Data,2)-1 ;Write first element as header (Column headings) If $Y = 0 Then $html &= ' <th>' & $Data[$Y][$X] & '</th>'& @CRLF Else $html &= ' <td>' & $Data[$Y][$X] & '</td>'& @CRLF EndIf Next $html &= ' </tr>'& @CRLF ;Alternate row colors If $RowColor = "RowColor1" Then $RowColor = "RowColor2" Else $RowColor = "RowColor1" EndIf Next $html &= '</table>'& @CRLF $html &= '</body>'& @CRLF $html &= '</html>'& @CRLF ;WRITE FILE $Handle = FileOpen($OutFile, 2) FileWrite($Handle, $html) FileClose($Handle) ;Print ShellExecute($OutFile,"","", "Print") EDIT: Added print dialog at the bottom Edited May 23, 2008 by weaponx Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now