|
-
May 23rd, 2003, 07:46 AM
#1
Thread Starter
Junior Member
read out a DB with VBA and indicate it in HTML ***not solved***
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|
-
May 23rd, 2003, 08:11 AM
#2
Re: read out a DB with VBA and indicate it in HTML ***not solved***
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
Uh?
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
Print
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
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 23rd, 2003, 08:35 AM
#3
Thread Starter
Junior Member
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|
-
May 23rd, 2003, 09:33 AM
#4
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:
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
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.
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 29th, 2003, 03:22 PM
#5
Hyperactive Member
Why so complicated? If it's VBA in Access as he says:
VB Code:
DoCmd.OutputTo acOutputTable, "Employees", acFormatHTML, "Employee.html", True
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|