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
  • 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 :)

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!
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.


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

Do email signature updates give you a headache?

Constantly trying to correctly format email signatures? Spending all of your time at every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

Question has a verified solution.

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

Zimbra is famous for its platform independency, ability to manage multiple user accounts, easy assimilation with 3rd party applications, social network certification etc. Here, we discuss about how users can move multiple Zimbra user accounts to Exc…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

861 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now