Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Generating HTML file

Posted on 1999-07-24
5
Medium Priority
?
156 Views
Last Modified: 2010-04-30
HI,
  I have a table in access and i want to generate a html file which is a report and which shows all the table contents. Iam writing the code in visual basic, but i don't know how to generate html files from visual basic. I don't know how to move from one record to another when doing this until the end of table is reached. Can u give some ideas and provide some examples for this, so that i can make progress.
Waiting for your reply
pat
0
Comment
Question by:pat_rick73
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 200 total points
ID: 1527279
to move to the next record you might wanna use data.recordset.movenext

an examle...

while not data.recordset.eof
....do whatever....

about generating HTML code...

you need to have a string which would contain the basic html tags when you start off... example..

dim str as string

str = "<html><head><title>DataBase Output</title></head><body><table>"

while not database.recordset.eof
str = str & "<tr><td>" & database.recordset.fields("firstname") & "</td><td>" & database.recordset.fields("lastname") & "</td></tr>"
......
'and finally close all the basic HTML parts including the table...
str = str & "</table></body></html>"

hope this more like a pseudo code helps you get your wok done...

..-=ViKtOr=-..
0
 

Author Comment

by:pat_rick73
ID: 1527280
Hi,
 I have written code like this and is woking pefectly,but I want to display like this

Field1    Field2       Facility  under facility I want to have two fields one with value and other with units.How should I do this.Earlier I have created like
Facility Value    Facility Units.


public Sub gen_table4(dest As Integer, rsSet As Recordset, per1 As Integer, _
per2 As Integer, per3 As Integer, per4 As Integer, _
head1 As String, head2 As String, head3 As String, head4 As String, _
col1 As String, col2 As String, col3 As String, col4 As String)


Print #dest, "<b>"
Print #dest, "<table BORDER=""1"" CELLSPACING=""1"" CELLPADDING=""7"" WIDTH=""100%"">"

'print the headings of each table
Print #dest, "<tr>"
    Print #dest, "<td WIDTH="""
    Print #dest, per1
    Print #dest, "%"" VALIGN=""top"" align=""center""><p ALIGN=""CENTER""><font face=""Arial"" size=""2""><b>"
    Print #dest, head1
    Print #dest, "</font></td></b>"
    Print #dest, "<td WIDTH="""
    Print #dest, per2
    Print #dest, "%"" VALIGN=""top"" align=""center""><p ALIGN=""CENTER""><font face=""Arial"" size=""2""><b>"
    Print #dest, head2
    Print #dest, "</font></td></b>"
    Print #dest, "<td WIDTH="""
    Print #dest, per3
    Print #dest, "%"" VALIGN=""top"" align=""center""><p ALIGN=""CENTER""><font face=""Arial"" size=""2""><b>"
    Print #dest, head3
    Print #dest, "</font></td></b>"
    Print #dest, "<td WIDTH="""
    Print #dest, per4
    Print #dest, "%"" VALIGN=""top"" align=""center""><p ALIGN=""CENTER""><font face=""Arial"" size=""2""><b>"
    Print #dest, head4
    Print #dest, "</font></td></b>"
  Print #dest, "</tr>"
Print #dest, "</b>"

'print the table contents over here
  For i = 1 To count
  Print #dest, "<tr>"
    Print #dest, "<td WIDTH="""
    Print #dest, per1
    Print #dest, "%"" VALIGN=""middle"" align=""center"">"
    Print #dest, rsSet.Fields(col1)
    Print #dest, "</td>"
    Print #dest, "<td WIDTH="""
    Print #dest, per2
    Print #dest, "%"" VALIGN=""middle"" align=""center"">"
    Print #dest, rsSet.Fields(col2)
    Print #dest, "</td>"
    Print #dest, "<td WIDTH="""
    Print #dest, per3
    Print #dest, "%"" VALIGN=""middle"" align=""center"">"
    Print #dest, rsSet.Fields(col3) '//Chg
    Print #dest, "</td>"
    Print #dest, "<td WIDTH="""
    Print #dest, per4
    Print #dest, "%"" VALIGN=""middle"" align=""center"">"
    Print #dest, rsSet.Fields(col4)
    Print #dest, "</td>"
  Print #dest, "</tr>"
  rsSet.MoveNext
  Next i

'print the end tag for the table
Print #dest, "</table>"
'If Not rsSet.BOF And Not rsSet.EOF Then
 rsSet.MoveFirst
'End If
End Sub
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1527281
I;m not sure what you mean.. could you somehow draw it with ASCII??

what it is now and what you want it to be,, thanks!
0
 

Author Comment

by:pat_rick73
ID: 1527282
Hi,
 I have done to display like this in a table format,with four field values.
Field1       Field2      FieldValue  FieldUnits

Now I want to have something like this where I want to show Field in one line,and in the next line I want to divide this column into two subcolumns, so that it will look good.

Field1      Field2          Field
            Value      Units

Sorry for inconvenience,if you are still not clear,then I can send this as an attachment,by drawing in a tabular fashion.bye
pat
 



0
 
LVL 10

Expert Comment

by:viktornet
ID: 1527283
I think that would be great if you can show me how you want it to look like...

okay now you have it like this..

______________
|F1  | F2 | V1 | V2 |
|___|___|___|___|

and  you want it like this?
_______
| F1 | F2 |
|___|___|
| V1| V2 |
|___|___|

Is that how you want to construct it?

well, you simply add an additional <TR>

Instead of having this....

<tr>
  <td>F1</td><td>F2</td><td>V1</td><td>V2</td>
</tr>


you will have the following....


<tr>
  <td>F1</td><td>F2</td>
</tr>
<tr>
  <td>V1</td><td>V2</td>
</tr>

do you understand what I mean? It's not that difficult, once you get the hang of it ;-))

..-=ViKtOr=-..
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question