Solved

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

Posted on 2014-07-25
13
389 Views
Last Modified: 2014-07-28
Hello,

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!
0
Comment
Question by:pcalabria
  • 7
  • 6
13 Comments
 
LVL 3

Expert Comment

by:Leo Alexander
ID: 40220532
Hello!

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.

Also,

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.

Leo
0
 

Author Comment

by:pcalabria
ID: 40220864
Leo,

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

Expert Comment

by:Leo Alexander
ID: 40220907
Sure--

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

Author Comment

by:pcalabria
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.
0
 
LVL 3

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.

Next,

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 like..it 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
0
 

Author Comment

by:pcalabria
ID: 40222688
Leo,

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!
0
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!

 
LVL 3

Expert Comment

by:Leo Alexander
ID: 40222807
Hi,

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

Author Comment

by:pcalabria
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...
0
 
LVL 3

Accepted Solution

by:
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
   
Catch:
    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--


Leo
0
 

Author Comment

by:pcalabria
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.

Thanks
0
 

Author Comment

by:pcalabria
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:
-2147467259
Automation Error
Unspecifed Error

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

Thanks
0
 

Author Closing Comment

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

Expert Comment

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

Featured Post

Do email signature updates give you a headache?

Do you feel like all of your time is spent managing email signatures? Too busy to visit 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!

Join & Write a Comment

Explore the encryption capabilities built into Google Apps and how these features can help you meet privacy policy and regulatory compliance, but are not a full solution. Understand and compare the most popular email encryption services for Google A…
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

759 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

18 Experts available now in Live!

Get 1:1 Help Now