The following code works well to create an html file that has a row
for each row in my table. My Access 2002 database has a tabel with 3
columns labeled, Model, CD and Hard Drive (HD). Any suggestions to
change the code to make one html page for each Model? Maybe run the
code on a table query?
Private Sub sCreateStaticHT MLFiles_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strHTMLFile As String
Set db = DBEngine(0)(0)
Set rs = db.OpenRecordse t("Table1")
strHTMLFile = "C:\data\" & Format(rs!Model , "000") & ".htm"
Open strHTMLFile For Output As #1
Print #1, "</TABLE>"
Print #1, "<TABLE BORDER=1>"
Print #1, "<TR bgcolor=E0E0E0
align=center><T D>CPU</TD><TD>Hard Drive</TD></TR>"
Do
Print #1, "<TR><TD>" & rs!CPU & "</TD><TD>" & rs!HD &
"</TD></TR>"
rs.MoveNext
Loop Until rs.EOF
Print #1, "</TABLE>"
Close #1
Exit Sub
End Sub 8 10327
Without trying to do a tutorial on HTML or write your code for you, you need
to determine what you want on the page, make sure your recordset is ordered
in that same manner, then use changes in the Model field to end/start a new
HTML page.
Because relational tables are, by definition, unordered, that means you'll
want to create a query with sort specified on the Model field (and whatever
other subsidiary sorts you may want).
AFAIK, an HTML page begins with the <HEAD> tag, followed by page heading
information, the heading ended by </HEAD>, and the body of the page begins
with <BODY>, the page body information (e.g., your data and formatting), and
the body and page end with the </BODY> tag. Also, AFAIK, your table can't
extend over two logical pages (the head-body definition may contain more
than a screenful of html, which you can scroll... or printed more than one
physical page).
Larry Linson
Microsoft Access MVP
"RC" <rc*********@ya hoo.com> wrote in message
news:3c******** *************** ***@posting.goo gle.com... The following code works well to create an html file that has a row for each row in my table. My Access 2002 database has a tabel with 3 columns labeled, Model, CD and Hard Drive (HD). Any suggestions to change the code to make one html page for each Model? Maybe run the code on a table query?
Private Sub sCreateStaticHT MLFiles_Click() Dim db As DAO.Database Dim rs As DAO.Recordset Dim strHTMLFile As String Set db = DBEngine(0)(0) Set rs = db.OpenRecordse t("Table1") strHTMLFile = "C:\data\" & Format(rs!Model , "000") & ".htm" Open strHTMLFile For Output As #1 Print #1, "</TABLE>" Print #1, "<TABLE BORDER=1>" Print #1, "<TR bgcolor=E0E0E0 align=center><T D>CPU</TD><TD>Hard Drive</TD></TR>" Do Print #1, "<TR><TD>" & rs!CPU & "</TD><TD>" & rs!HD & "</TD></TR>" rs.MoveNext Loop Until rs.EOF Print #1, "</TABLE>" Close #1 Exit Sub End Sub
Private Sub sCreateStaticHT MLFiles_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strHTMLFile As String
Set db = DBEngine(0)(0)
Set rs = db.OpenRecordse t("Table1")
Do
strHTMLFile = "C:\data\" & Format(rs!Model , "000") & ".htm"
Open strHTMLFile For Output As #1
Print #1, "</TABLE>"
Print #1, "<TABLE BORDER=1>"
Print #1, "<TR bgcolor=E0E0E0 align=center><T D>CPU</TD><TD>Hard
Drive</TD></TR>"
Print #1, "<TR><TD>" & rs!CPU & "</TD><TD>" & rs!HD & "</TD></TR>"
Print #1, "</TABLE>"
Close #1
rs.MoveNext
Loop Until rs.EOF
End Sub
Darryl Kerkeslager
"RC" <rc*********@ya hoo.com> wrote in message
news:3c******** *************** ***@posting.goo gle.com... The following code works well to create an html file that has a row for each row in my table. My Access 2002 database has a tabel with 3 columns labeled, Model, CD and Hard Drive (HD). Any suggestions to change the code to make one html page for each Model? Maybe run the code on a table query?
Private Sub sCreateStaticHT MLFiles_Click() Dim db As DAO.Database Dim rs As DAO.Recordset Dim strHTMLFile As String Set db = DBEngine(0)(0) Set rs = db.OpenRecordse t("Table1") strHTMLFile = "C:\data\" & Format(rs!Model , "000") & ".htm" Open strHTMLFile For Output As #1 Print #1, "</TABLE>" Print #1, "<TABLE BORDER=1>" Print #1, "<TR bgcolor=E0E0E0 align=center><T D>CPU</TD><TD>Hard Drive</TD></TR>" Do Print #1, "<TR><TD>" & rs!CPU & "</TD><TD>" & rs!HD & "</TD></TR>" rs.MoveNext Loop Until rs.EOF Print #1, "</TABLE>" Close #1 Exit Sub End Sub
Oops. read Larry's post and realized I left off the <html><head>, and <body>
tags.
Add first Print# statement: Print #1, "<html><hea d></head><body>"
Add last Print# statement: Print #1, "</body></html>"
Darryl Kerkeslager
Thanks for you help. The following (adjusted) code creates an one htm
page for each AuctionLotNumbe r, but, it only grabs the first record it
sees for that AuctionLotNumbe r and then stops. If there are 6 records
that have the same AuctionLotNumbe r then the htm page should show a
table with 6 rows. I have been messing around with queries and
For-Each loops but I'm not getting anywhere.
"Darryl Kerkeslager" <Ke*********@co mcast.net> wrote in message news:<dc******* *************@c omcast.com>... Oops. read Larry's post and realized I left off the <html><head>, and <body> tags.
Add first Print# statement: Print #1, "<html><hea d></head><body>" Add last Print# statement: Print #1, "</body></html>"
Darryl Kerkeslager
RC,
"RC" <rc*********@ya hoo.com> wrote: Thanks for you help. The following (adjusted) code creates an one htm page for each AuctionLotNumbe r, but, it only grabs the first record it sees for that AuctionLotNumbe r and then stops. If there are 6 records that have the same AuctionLotNumbe r then the htm page should show a table with 6 rows. I have been messing around with queries and For-Each loops but I'm not getting anywhere.
Re-read your Original post several times and I see no mention of
AuctionLotNumbe r:
My Access 2002 database has a tabel with 3 columns labeled, Model, CD and Hard Drive (HD). Any suggestions to change the code to make one html page for each Model?
The code modifications I posted does what you asked: "make one html page
for each Model"
Is there more to it?
(Here the two post are combined)
Private Sub sCreateStaticHT MLFiles_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strHTMLFile As String
Set db = DBEngine(0)(0)
Set rs = db.OpenRecordse t("Table1")
Do
strHTMLFile = "C:\data\" & Format(rs!Model , "000") & ".htm"
Open strHTMLFile For Output As #1
Print #1, "<html><hea d></head><body>"
Print #1, "<TABLE BORDER=1>"
Print #1, "<TR bgcolor=E0E0E0 align=center><T D>CPU</TD><TD>Hard
Drive</TD></TR>"
Print #1, "<TR><TD>" & rs!CPU & "</TD><TD>" & rs!HD & "</TD></TR>"
Print #1, "</TABLE></body></html>"
Close #1
rs.MoveNext
Loop Until rs.EOF
End Sub
Darryl Kerkeslager
Sorry, my fault, I swapped AuctionLotNumbe r for Model. The code makes
one html page for each Model or AuctionLotNumbe r (I'll stick with
Model) but each page has only the first record for that Model. I need
to make one html page for each Model and that page should have one
table and each row of the table should have the CD and HD for a Model
with as many rows in the table as there are of that particular Model
in the database. One Model may have many different configurations of
CPU and Hard Drive. Then the next html page has the info for a
different Model. For example.
<HTML>
<HEAD>Web page for Dell T21 Laptop Model</HEAD>
<BODY>
<TABLE BORDER=1>
<TR bgcolor=E0E0E0 align=center><T D>cpu</TD><TD>Hard drive</td></TR>
<TR><TD>800 MHz</TD><TD>20 Gig</TD></TR>
<TR><TD>933 MHz</TD><TD>18 Gig</TD></TR>
<TR><TD>1.2 GHz</TD><TD>32 Gig</TD></TR>
</TABLE>
</BODY></HTML>
Sorry for the missing details in the previous posts.
"Darryl Kerkeslager" <Ke*********@co mcast.net> wrote in message news:<uK******* *************@c omcast.com>... RC,
"RC" <rc*********@ya hoo.com> wrote:
Thanks for you help. The following (adjusted) code creates an one htm page for each AuctionLotNumbe r, but, it only grabs the first record it sees for that AuctionLotNumbe r and then stops. If there are 6 records that have the same AuctionLotNumbe r then the htm page should show a table with 6 rows. I have been messing around with queries and For-Each loops but I'm not getting anywhere.
Re-read your Original post several times and I see no mention of AuctionLotNumbe r:
My Access 2002 database has a tabel with 3 columns labeled, Model, CD and Hard Drive (HD). Any suggestions to change the code to make one html page for each Model?
The code modifications I posted does what you asked: "make one html page for each Model" Is there more to it?
(Here the two post are combined)
Private Sub sCreateStaticHT MLFiles_Click() Dim db As DAO.Database Dim rs As DAO.Recordset Dim strHTMLFile As String Set db = DBEngine(0)(0) Set rs = db.OpenRecordse t("Table1") Do strHTMLFile = "C:\data\" & Format(rs!Model , "000") & ".htm" Open strHTMLFile For Output As #1 Print #1, "<html><hea d></head><body>" Print #1, "<TABLE BORDER=1>" Print #1, "<TR bgcolor=E0E0E0 align=center><T D>CPU</TD><TD>Hard Drive</TD></TR>" Print #1, "<TR><TD>" & rs!CPU & "</TD><TD>" & rs!HD & "</TD></TR>" Print #1, "</TABLE></body></html>" Close #1 rs.MoveNext Loop Until rs.EOF End Sub
Darryl Kerkeslager
Okay. The easiest way to do it is to sort your table by model, so that you
can iterate through it one record at a time, starting a new html file when
the model number changes. The code below is wordy, but should work. You
should include error handling anytime you do file i/o.
Darryl Kerkeslager
-------------------------------------------------------------------------
Private Sub sCreateStaticHT MLFiles_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strHTMLFile As String
Dim s As String
Set db = DBEngine(0)(0)
Set rs = db.OpenRecordse t("SELECT * FROM Table1 ORDER BY Model")
If rs.EOF Then
MsgBox "Empty Table"
Exit Sub
Endif
s = Trim(rs!Model)
Open strHTMLFile For Output As #1
Print #1, "<html><hea d></head><body><TAB LE BORDER=1>"
Print #1, "<TR bgcolor=E0E0E0 align=center><T D>CPU</TD><TD>Hard
Drive</TD></TR>"
Do
If StrComp(s, Trim(rs!Model), vbTextCompare) <> 0 Then ' New file
if diff Model
Print #1, "</TABLE></body></html>"
Close #1
s = Trim(rs!Model)
strHTMLFile = "C:\data\" & Format(s, "000") & ".htm"
Open strHTMLFile For Output As #1
Print #1, "<html><hea d></head><body><TAB LE BORDER=1>"
Print #1, "<TR bgcolor=E0E0E0
align=center><T D>CPU</TD><TD>Hard Drive</TD></TR>"
EndIf
Print #1, "<TR><TD>" & rs!CPU & "</TD><TD>" & rs!HD & "</TD></TR>"
rs.MoveNext
Loop Until rs.EOF
Print #1, "</TABLE></body></html>"
Close #1
End Sub
----------------------------------------------------------------------------
--------------
"RC" <rc*********@ya hoo.com> wrote in message
news:3c******** *************** ***@posting.goo gle.com... Sorry, my fault, I swapped AuctionLotNumbe r for Model. The code makes one html page for each Model or AuctionLotNumbe r (I'll stick with Model) but each page has only the first record for that Model. I need to make one html page for each Model and that page should have one table and each row of the table should have the CD and HD for a Model with as many rows in the table as there are of that particular Model in the database. One Model may have many different configurations of CPU and Hard Drive. Then the next html page has the info for a different Model. For example.
<HTML> <HEAD>Web page for Dell T21 Laptop Model</HEAD> <BODY> <TABLE BORDER=1> <TR bgcolor=E0E0E0 align=center><T D>cpu</TD><TD>Hard drive</td></TR> <TR><TD>800 MHz</TD><TD>20 Gig</TD></TR> <TR><TD>933 MHz</TD><TD>18 Gig</TD></TR> <TR><TD>1.2 GHz</TD><TD>32 Gig</TD></TR> </TABLE> </BODY></HTML>
Sorry for the missing details in the previous posts.
Voila! You are a genius. Thank you! The code works perfect. I am
very happy. Very nice loop, I like the way it works, I learned from
it and will use it in the future. Thanks for teaching me a few
things. I didn't know you could "Order By" during the "Set rs =
db.OpenRecordse t("SELECT *".
And I will study this line:
"If StrComp(s, Trim(rs!Model), vbTextCompare) <> 0 Then"
I am not familiar with StrComp.
The only thing I changed was to add the line to set the file
path/name.
"Darryl Kerkeslager" <Ke*********@co mcast.net> wrote in message news:<QJ******* *************@c omcast.com>... Okay. The easiest way to do it is to sort your table by model, so that you can iterate through it one record at a time, starting a new html file when the model number changes. The code below is wordy, but should work. You should include error handling anytime you do file i/o.
Darryl Kerkeslager
------------------------------------------------------------------------- Private Sub sCreateStaticHT MLFiles_Click() Dim db As DAO.Database Dim rs As DAO.Recordset Dim strHTMLFile As String Dim s As String Set db = DBEngine(0)(0) Set rs = db.OpenRecordse t("SELECT * FROM Table1 ORDER BY Model") If rs.EOF Then MsgBox "Empty Table" Exit Sub Endif s = Trim(rs!Model)
strHTMLFile = "C:\data\" & Format(rs!Model , "000") & ".htm"
Open strHTMLFile For Output As #1 Print #1, "<html><hea d></head><body><TAB LE BORDER=1>" Print #1, "<TR bgcolor=E0E0E0 align=center><T D>CPU</TD><TD>Hard Drive</TD></TR>" Do If StrComp(s, Trim(rs!Model), vbTextCompare) <> 0 Then ' New file if diff Model Print #1, "</TABLE></body></html>" Close #1 s = Trim(rs!Model) strHTMLFile = "C:\data\" & Format(s, "000") & ".htm" Open strHTMLFile For Output As #1 Print #1, "<html><hea d></head><body><TAB LE BORDER=1>" Print #1, "<TR bgcolor=E0E0E0 align=center><T D>CPU</TD><TD>Hard Drive</TD></TR>" EndIf Print #1, "<TR><TD>" & rs!CPU & "</TD><TD>" & rs!HD & "</TD></TR>" rs.MoveNext Loop Until rs.EOF Print #1, "</TABLE></body></html>" Close #1 End Sub
---------------------------------------------------------------------------- --------------
"RC" <rc*********@ya hoo.com> wrote in message news:3c******** *************** ***@posting.goo gle.com... Sorry, my fault, I swapped AuctionLotNumbe r for Model. The code makes one html page for each Model or AuctionLotNumbe r (I'll stick with Model) but each page has only the first record for that Model. I need to make one html page for each Model and that page should have one table and each row of the table should have the CD and HD for a Model with as many rows in the table as there are of that particular Model in the database. One Model may have many different configurations of CPU and Hard Drive. Then the next html page has the info for a different Model. For example.
<HTML> <HEAD>Web page for Dell T21 Laptop Model</HEAD> <BODY> <TABLE BORDER=1> <TR bgcolor=E0E0E0 align=center><T D>cpu</TD><TD>Hard drive</td></TR> <TR><TD>800 MHz</TD><TD>20 Gig</TD></TR> <TR><TD>933 MHz</TD><TD>18 Gig</TD></TR> <TR><TD>1.2 GHz</TD><TD>32 Gig</TD></TR> </TABLE> </BODY></HTML>
Sorry for the missing details in the previous posts. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: bissatch |
last post by:
Hi,
I am currently working on a content management system where a user can
fill in a form (title, keywords, link text etc. - all the initial
attibutes), which when submitted, will go onto create a web page.
The code is as follows:
$html = "<html>\n<body>\n<p>Hello World</p>\n</body>\n<html>";
$handle = fopen($_SERVER."/path/to/folder/".$filename,
|
by: David Elliott |
last post by:
I can create this:
?xml version="1.0" standalone="yes" ?>
<ConfigOpt>
<record>
<Field_1>Text # 1</Field_1>
<Field_2>Text # 2</Field_2>
</record>
</ConfigOpt>
|
by: dog |
last post by:
I've seen plenty of articles on this topic but none of them have been
able to solve my problem.
I am working with an Access 97 database on an NT4.0 machine, which has
many Access reports.
I want my users to be able to select a report, click on a command
button on a form, which will then automatically create the report as a
pdf file and save it to the user's machine.
I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
|
by: Marc Miller |
last post by:
Hi all,
I have 2 dev. machines, the 1st is Win 2000 with .NET 7.0 and the 2nd is XP
Pro with .NET 2003. My Web Server is Win 2000 Server with IIS 5.0.
I can create a new project on my test server from the 1st machine, but I
receive an 'HTTP/1.1 500 Internal Server error" from my Web Server.
My userid/password are the same on all 3 machines.
|
by: windandwaves |
last post by:
Hi Folk
Some of my clients asked me to create "fancy emails" for them (aka html
formatted emails).
I know how to make a nice html document, but I had trouble creating a simple
way to provide the document to my clients so that they could use it to.
I know most of them use Outlook XP or Outlook 2003, so what I created was a
page that creates a Visual Basic script that, when saved to the desktop and
| |
by: barb |
last post by:
So that the world at large benefits from our efforts, here is one fully
documented way to use Windows Irfanview freeware to create thumbnail web
galleries (http://www.irfanview.com).
STEP 1: Start with original thumbnails & two empty sub directories
STEP 2: Create smaller versions of the originals for one sub directory
STEP 3: Create thumbnail version of the originals the other sub directory
STEP 4: Create an index.html pointing to the...
|
by: susinthaa |
last post by:
Hi
I tried to create a file using sysopen command as the following
sysopen( SUSI,'c:\\susi.html',O_RDWR|O_EXCL|O_CREAT, 0755);
printf HTML "<html>\n";
printf HTML "<head>\n";
printf HTML "<title>Susintha Home page</title>;
printf HTML "</head>\n";
printf HTML "<body>\n";
|
by: rohitkumar |
last post by:
i have a database having records of no. of people. i have to create no. of HTML files depending upon the no. of rows retrieved from database. i m creating a single html file using
StringBuilder HTML = new StringBuilder();
String NewLine = System.Environment.NewLine;
HTML.Append("<HTML>" + NewLine + "<head>" + NewLine);
HTML.Append("<title>" + client_name + "</title>" + NewLine + "</head>" + NewLine);
HTML.Append("<body...
|
by: lxyone |
last post by:
Using a flat file containing table names, fields, values whats the
best way of creating html pages?
I want control over the html pages ie
1. layout
2. what data to show
3. what controls to show - text boxes, input boxes, buttons,
hyperlinks ie the usual.
The data is not obtained directly from a database.
|
by: TrevRex |
last post by:
Hello,
I work for a non-profit in San Diego as a GIS Specialist. I have had to teach myself about some scripting to create some dynamic maps, but I am still very limited in my skills, so I have had to explore the internet in order to discover various tutorials and examples that have led me on a positive path.
Right now I am working on a Google Mash-Up that will incorporate over 14,000 records, which will appear as separate markers that...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |