WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Access

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Query and Export Data from Microsoft Access

Keywords:   Query and Export Data from Microsoft Access 

;   here's a quick and dirty script I use to look at data in a
;   ms access database, you might be able to modify it for your
;   own uses.

#DefineSubRoutine startMSIE()
   Browser = ObjectOpen("InternetExplorer.Application")
   Browser.addressbar = @FALSE
   Browser.statusbar = @FALSE
   Browser.menubar = @FALSE
   Browser.toolbar = @FALSE
;   Browser.fullscreen = @true
   browser.visible = @TRUE
   url = "c:\RiftsPC-URL.html"
   browser.navigate(url)
   WaitForPageLoad()
   ;   setup the document object...
   browserDoc = Browser.Document
   all = browserdoc.all
   Return(browser)
#EndSubRoutine

#DefineSubRoutine WaitForPageLoad()  ; assume Browser
   While browser.busy || browser.readystate == 1
      TimeDelay(0.5)
   EndWhile
   While browser.Document.ReadyState != "complete"
      TimeDelay(0.5)
   EndWhile
   Return
#EndSubRoutine



accessDB = ObjectOpen("Access.Application")
ADB = accessDB.Application
dbname = "C:\RGMC\rgmc.mdb"            ;  <---------- change to your database
ADB.OpenCurrentDatabase(dbname)
ADB.Visible = @FALSE
db = accessDB.currentdb

GoSub displaytabledata

Message("Debug", "all done")

Return
Exit

:displaytabledata

table = AskLine("Rifts", "Enter Table", "table")

sqlstr = StrCat("select * from [", table, "] order by 1 asc;")

rs = db.openrecordset(sqlstr)
x = startMSIE()
browserdoc.writeln("<title>MS Access</title><body><h2>Data Listing</h2><hr>")
tf = rs.fields
tfc = tf.count
While !rs.eof
   Yields(25)
   For fd = 0 To tfc-1
      fld = rs.fields(fd)
      browserdoc.writeln('<table border=1 style="BORDER-COLLAPSE: collapse">')
      browserdoc.writeln(StrCat("<tr><td width=200><b>", fld.name, "</b></td><td width=500><font size=-1 color=blue>", fld.value, "</font></td></tr>"))      
      browserdoc.writeln('</table>')
   Next
   browserdoc.writeln("<br><br>")
   rs.movenext
EndWhile

rs.close
Return

Article ID:   W15620
File Created: 2004:08:02:11:00:22
Last Updated: 2004:08:02:11:00:22