How To Create A Local Web Page With Access DB Data PT1

This is going to be a multiple part blog post, but here I am clicking a command button on a form and then taking the data
from a query called “qrySecondaryContainmenttodrain”, and creating a html page called “containment_inspections.htm”.

(You will have to modify the query and the html page so it will fit your need)

The html database is basically a SQLLite database using the WebSQL functionality of the browser.

This really won’t show anything on the web browser, but if you press the “Ctrl + Shift + I” key sequence on you Chrome web browser, and click on the “Applications” tab, and go to the “WebSQL” area, you’ll see that a database was created.

That’s the first step to conquer.

The plan is to create a tool that a person who works in the field can load onto an electonic device like a tablet or cellphone, take into the field, and scan and enter the inspected equipment, view what the Access database says about the equipment, then the user can report their inspection results on their electronic device, and then reload the entries into the Access database.

The next steps are

-to display the data on the screen.
-to create a functional html form for the user to interact with their results.
-export the results in csv format so they can reload back in to the Access database

Here is the code so far:

Sub GenerateContainmentInspectionsHTML()

    Dim intRandomDB As Integer
    Dim intSeed As Integer
    Dim strDB As String
    
    'this is seed value for the RND function's random number generator.
    Randomize
    
    'Int ((upperbound - lowerbound + 1) * Rnd + lowerbound)
    intRandomDB = Int((2500 - 1 + 1) * Rnd(2) + 10)
    Debug.Print intRandomDB
    strDB = "inspdb" & intRandomDB
    
    strPath = CurrentProject.Path & "\containment_inspections.htm"
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    strSQL = "SELECT * FROM qrySecondaryContainmenttodrain"
    
    Set rst = CurrentDb.OpenRecordset(strSQL)
    rst.MoveFirst
    
    Dim objFile As Object
    Set objFile = fso.CreateTextFile(strPath, True, True)
    objFile.write " " & vbCrLf & vbCrLf

    objFile.write "" & vbCrLf
       objFile.write "" & vbCrLf
            objFile.write "" & vbCrLf
          objFile.write "" & vbCrLf & vbCrLf
    
       objFile.write "" & vbCrLf & vbCrLf
      
       objFile.write "" & vbCrLf
          
          
       objFile.write "" & vbCrLf
    objFile.write ""

    
    
     MsgBox "Complete"
 
    
End Sub

Let me know if you have any questions so far.




By the way, if you got or are getting value from the VBA information, please click the "Donate" button to give me a small token of your appreciation, thanks!


These posts may help answer your question too...

Learn Access VBA: Understand Tables, Queries, Forms, and Reports

Learn Access VBA: From Zero to Database Hero If you’ve ever opened Microsoft Access and wondered how all the pieces fit together — tables, queries, forms, and reports — this tutorial is made for you. In just a few minutes, you’ll understand how Access works behind the scenes and see how VBA (Visual Basic for […]

How To Escape Apostrophe In SQL Update Query

If you are looping a table with thousands of records, you’ll probably run into at least one that has an apostrophe in the field name. Like “Mike’s” or “M’cormick”, or something else. Anyway, here is one way to escape the string when you are doing your update query. Option Compare Database Sub YDriveLoop() ‘4/23/24 erik@loeblcomservices.com […]

How To Parse A Flat File In Excel VBA

In another post I demonstrated how to access a file on your computer using the MS Office Library. Here it is if you don’t know what I’m talking about. In this post, I am going to show you how to access the file and load it into your spreadsheet. I will do the same thing […]

How can I interact with other Office applications (Excel) using VBA in Access?

Need to write your Access data or query to an Excel file? Here is the how to do it: Most people are familiar with Excel and know how to use it well (enough), and when you start talking about Access, they get scared off, and don’t know what to do anymore. Well, here you are […]


Support these sponsors:
Previous Post

Client Side Storage Access And WebSQL Database Part2

Next Post

How To Integrate Access With An HTML Page