High folks.
I have to readout a database with VBA and indicate it into a HTML. But it don't have a clue how to slove that :)
I didn't work yet with VBA. Perhaps you can help me...
thx in advise
|proud to be a devil|
High folks.
I have to readout a database with VBA and indicate it into a HTML. But it don't have a clue how to slove that :)
I didn't work yet with VBA. Perhaps you can help me...
thx in advise
|proud to be a devil|
Uh?Quote:
Originally posted by ReDmAn
I have to readout a database with VBA and indicate it into a HTML. But it don't have a clue how to slove that :)
You mean use VBA to read a db (Access?) and output the results in a file HTML?
If so you need to read up on the following in the help files to do with outputing files:
Open
Close
Line Input
Then you need to know how to retrieve the data and loop through it then combine that to the file output bits above.
Of look at Docmd.OutputTo...
Vince
your right!!!
It's an access-db which I have to read out. And the results must be shown in a html-sheet.
How can I read out the database?
Perhaps you can post a tutorial how to readout a fields of the db?!?
thx in advise
|proud to be a devil|
First up,
- do you know how to write HTML from scratch?
- do you know how to retrieve record and put them into text boxes on a form (its going to be similar to this but to the file)
If you can write HTML, rough out how you want it to look as a html file (no data though).
Simplistic code - DAO:
I think that will work - if not, you should pick up the gist of it. Note: its in DAO and running from Access, if you are coming from an external package (Excel, VB whatever) you need to connect properly.VB Code:
Sub TestHTML() Dim rst as recordset Dim strSql as string, strFilename as string, strOutput as string Dim lngFlds as long On Error Resume Next '---- set the output file name strFilename = "C:\Test.htm" '---- if file exists - delete it (no return delete) if nz(len(dir$(strfilename,63)),0)>0 then kill strfilename '---- close any open file (just in case) and open the file Close #1 Open strFilename For Output As #1 print #1,"<html><head><title>Test HTML Export</title></head><body>" strsql = "Select * from tblReq" set rst = dbengine(0)(0).openrecordset(strsql) if err.number=0 then if not rst.eof then do until rst.eof stroutput="" for lngFlds = 0 to rst.fields.count -1 stroutput = stroutput & iif(lngflds=0,"",",") & nz(rst(lngflds),"") next stroutput=stroutput & "<br>" print #1,stroutput rst.movenext loop end if end if print #1,"</body></html>" Close #1 if err.number=0 then msgbox "Completed" else msgbox "Error : " & err.number & vbcrlf & err.description endif set rst = nothing End Sub
Vince
Why so complicated? If it's VBA in Access as he says:VB Code:
DoCmd.OutputTo acOutputTable, "Employees", acFormatHTML, "Employee.html", True