PDA

View Full Version : Scripting



ProteanBeing
04-15-2008, 03:11 PM
How do I do this: set db = currentdb() in vbscript?

Trevor
04-15-2008, 03:28 PM
Dim qryDB As DAO.Database ' set a variable to = Database
Dim loRst As DAO.Recordset ' set variable for the record set in db
with loRSt
Do Until .EOF

' your condionions here
.moveNext ' to move to the next record
Loop
End With
LoRst.Close
Set qryDB = Nothing: set LoRst = Nothing
End Sub

or with Dim Db = CurrentDB()

Dim Db = CurrdntDb(querynamehere)
'or
Dim db = CurrentDb(sql query here)

ProteanBeing
04-16-2008, 06:08 AM
How do I do this: set db = currentdb() in vbscript?

This does not work in VBScript (all variables are variant only)

Trevor
04-16-2008, 07:49 AM
oh... now i get it the title of your post seemed a little odd when I replied, you want it in vbscript.
by why vbscript? why not do it in Access, VBA?

ProteanBeing
04-16-2008, 09:30 AM
I am using 2003 and trying to make a data access page do what I need it to.

Trevor
04-16-2008, 10:20 AM
ok, but I think access pages when reffering to tables works (or should work) like like an .MDB but then I also haven't had a need to work with access pages so I could be wrong, check this link out, it should atleast get you started
http://techtasks.com/code/viewbookcode/1256

ProteanBeing
04-16-2008, 03:28 PM
This did not help. Still need help.

ben.oates
04-18-2008, 04:03 AM
Isn't it just one of the following depending on your preference?

DAO example - JET Connection
Dim ws as Workspace
Dim db as Database
Set ws=DBEngine.Workspaces(0)
set db=ws.OpenDatabase({databasepath and name})

DAO example - ODBC Connection
Dim ws as Workspace
dim db as database
dim strConnection as string
set ws=DBEngine.Workspaces(0)
let strConnection= "ODBC;DSN=" & DatabaseName & ";UID=" & UserName & ";PWD=" & UserPassword
set db=ws.OpenDatabase("", False, False, strConnection)

ADO Example
Dim ad as ADODB.Connection
set ad=New ADODB.Connection
Let ad.ConnectionString= "ODBC;DSN=" & DatabaseName & ";UID=" & UserName & ";PWD=" & UserPassword
ad.Open