Need method to view HTML code in a table using a browser from MS Access

Posted on 2014-07-25
Last Modified: 2014-07-28

I am writing code to allow automatic uploading of pages to eBay.

The code uses a table that has a memo field that my routine has populated with HTML code.  

Is there a good way that I can view the code generated from a browser before I upload it to eBay?

Currently, I need to select a cell, copy the code, paste into notepad, save a file, the navigate to the file with a browser.  There must be a better way!

Your help is appreciated!
Question by:pcalabria
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
  • 7
  • 6

Expert Comment

by:Leo Alexander
ID: 40220532

If your code is in the table, specifically the Memo field, you can use the Docmd export function and have that information exported to a location of your choosing. It can be done in a text or Excel format.


You may opt to create a query that reads just that field and displays the information in a preview form for you as well via a report.


Author Comment

ID: 40220864

I'm intrigued by your idea to write the query... and the preview form... can you expand on that thought?

Expert Comment

by:Leo Alexander
ID: 40220907

Are you using any front-end forms or are you putting the code into a module?

I can upload a sample showing you what I am referring to, as I am not sure the written out explanation will be as beneficial... hang tight :)
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.


Author Comment

ID: 40221237
I use a front end form.
An OnClick event of a command button creates a table that includes a column called [*Description]
The  [*Description] field of tblSelectedParts contains the HTML code that I want to view.

Expert Comment

by:Leo Alexander
ID: 40221804
Okay, great--

What you can do is after that on click Event (i prefer to use the [Event Procedure] as it gives more flexibility with the code, have an additional directive to then display the result of that description field from the table.

All you need to do is create a query that points to the tblSelectedParts. Make sure you have a primary field, i.e. the current record and the *Description field selected in the query. If you choose not to include the primary/ID field, you will return all the records in that table--unless you don't mind this.


In the query, assuming you want to view just that particular record that you created (unless the whole table is created each time) you must create a filter. I would suggest using an append query from your form so that you can have a history of your information as opposed to creating a brand new table each time.

If you choose to do the filter method: in the criteria section of the query put this code: Forms!yourformname!fieldthathastheID

This will just return the *Description for that particular record you are viewing in the form.
IF you want all the results/no filter...just leave that part out.

Create a report based on that query..the source of that report is the query you just created.

You should be able to open the report by itself and see the content. Now, just call this report after you click your form button that is generating the data as such:

(You may need to change to [Event PRocedure] in the onclick button property)

Dim Report as String

Report = "rptNameOfMyReport

Docmd.OpenReport Report, acPreview

You can exclude the DIm and the assigning of the variable if you'd just makes it easier if you need to refer to the report multiple times within the sub.

Let me know how you make out... feel free to attach your db and i can make the mods for you, if you'd like

Author Comment

ID: 40222688

Thanks.  I am making progress, but can use some help.

First, and most important, I have created a report.  Now how to I get to view the HTML code that is populated in the *Description field?

I created a recordsource of SelectedParts and a txtBox with the source of *Description.
(My thought is to get this working before I attempt to select a single record).

The text only displays in the box as text.
What I want to do is the text the way it will be displayed in a browser.

Once I get to see results, we can figure out how to display just one record.  That sounds like the easy part.
I do have a primary key in the SelectedParts table called ID.

Thanks in advance!

Expert Comment

by:Leo Alexander
ID: 40222807

I may have misunderstood from what you originally wrote: Do you desire to view the HTML as the output (how it displays on the web) or as the RAW back-end code? I was under the impression you were looking for the latter, and not the output view.

Please confirm. If the former is the case, then we will need to output that result via a web browser.

Author Comment

ID: 40222839
Yes, the former case.

The code that I create programmatically becomes an ebay webpage once uploaded with ebay's file exchange.
My application programmatically creates HTML code, but I have no way to view and edit it, other than saving the code to notepad, and then opening with a browser.

There's got to be a better way... rather than save the code to a temp file and then shell to explorer...

Accepted Solution

Leo Alexander earned 500 total points
ID: 40222965
I have looked in to this a lot further and it appears that (from what i've tried and found) saving a temporary file and shelling to explorer (or browser of choice is the only option)

I can suggest to have the file saved to the same location with the same name, and then run the shell to open that way:

With that, you may create the Function:

Function OpenDocument(ByVal strLink As String) As Boolean
    On Error GoTo Catch
    Dim objBrowser As Object

    Set objBrowser = CreateObject("InternetExplorer.application")
    objBrowser.Visible = True
    objBrowser.Navigate strLink

    Exit Function
    OpenDocument3 = False
    MsgBox "Error#:  " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Function

Then call it within the button in your form:

OpenDocument ("C:\text.html")

I know this isn't ideal to your desired solution, but it may be the only alternative as the html needs to be parsed somehow..i am not sure if it can be compiled while still within the access application.

Let me know your thoughts--


Author Comment

ID: 40224211
Thanks for the code.   I was afraid this was what I would have to do, although the though of having the HTML appear in a report was exciting... :-)

The problem with using this code is record selection, and I am wondering whether there is a feature of Access that I don't know about that will solve my problem.

I click a button which displays a query with 15 or so columns.
These columns are mostly number and short text fields that are easy to view.
The description column, however, provides no view benefit unless viewed in the browser.
Is there a way that I can select on row, then click a command button, and have the command button recognize the row that has been clicked?  I am wondering whether the record selector function can be used.

In other words, if I click a button called VIEW HTML, can I with VBA read the selected field?

strDescription = ????

Once I have the code loaded into strDescription the rest of the routine would be easy.


Author Comment

ID: 40224388
I'm getting an error message when the following lines of code executes:

Dim objBrowser As Object
Set objBrowser = CreateObject("InternetExplorer.application")

The error is:
Automation Error
Unspecifed Error

What am I doing wrong?
Do I need to set a reference?


Author Closing Comment

ID: 40225809
I wound up doing something very similar, but you certainly gave me the idea!  Thanks

Expert Comment

by:Leo Alexander
ID: 40225951
Glad I could help, best of luck!

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

730 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