Results 1 to 5 of 5

Thread: read out a DB with VBA and indicate it in HTML ***not solved***

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2002
    Location
    Germany, Baden - Würtemberg
    Posts
    19

    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|

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    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

    BOFH Now, BOFH Past, Information on duplicates

    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...

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2002
    Location
    Germany, Baden - Würtemberg
    Posts
    19
    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|

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    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:
    1. Sub TestHTML()
    2.    Dim rst as recordset
    3.    Dim strSql as string, strFilename as string, strOutput as string
    4.    Dim lngFlds as long
    5.  
    6.    On Error Resume Next
    7.  
    8. '---- set the output file name
    9.    strFilename = "C:\Test.htm"
    10.  
    11. '---- if file exists - delete it (no return delete)
    12.    if nz(len(dir$(strfilename,63)),0)>0 then kill strfilename
    13.  
    14. '---- close any open file (just in case) and open the file
    15.    Close #1
    16.    Open strFilename For Output As #1
    17.    
    18.    print #1,"<html><head><title>Test HTML Export</title></head><body>"
    19.  
    20.    strsql = "Select * from tblReq"
    21.    set rst = dbengine(0)(0).openrecordset(strsql)
    22.  
    23.    if err.number=0 then
    24.       if not rst.eof then
    25.          do until rst.eof
    26.              stroutput=""
    27.              for lngFlds = 0 to rst.fields.count -1
    28.                stroutput = stroutput & iif(lngflds=0,"",",") & nz(rst(lngflds),"")
    29.              next
    30.              stroutput=stroutput & "<br>"
    31.  
    32.              print #1,stroutput
    33.  
    34.              rst.movenext
    35.          loop
    36.       end if
    37.  
    38.    end if
    39.  
    40.     print #1,"</body></html>"
    41.  
    42.    Close #1
    43.  
    44.    if err.number=0 then
    45.      msgbox "Completed"
    46.    else
    47.      msgbox "Error : " & err.number & vbcrlf & err.description
    48.    endif
    49.  
    50.    set rst = nothing
    51. 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

    BOFH Now, BOFH Past, Information on duplicates

    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...

  5. #5
    Hyperactive Member
    Join Date
    Mar 2002
    Posts
    424
    Why so complicated? If it's VBA in Access as he says:
    VB Code:
    1. 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
  •  



Click Here to Expand Forum to Full Width