[AccessD] A Question of Timing

Hale, Jim Jim.Hale at FleetPride.com
Thu Jan 4 10:58:18 CST 2007


If you are going to use seek on back end tables you will need to set the
database variable using a function like WhichDB.
HTH 
Jim Hale

Function CurrYear() As Integer
Dim strTable As String, db As Database, rs As Recordset
'find current month in periods table
    strTable = "tblPeriods"
    Set db = WhichDB(strTable)
    Set rs = db.OpenRecordset(strTable, dbOpenTable)
    'find record with the current year
    rs.Index = "fldStatus"
    rs.Seek "=", "B"
    CurrYear = rs.Fields("fldYear")
   

Function WhichDB(strTableName As String) As Database
Dim dbpath$, SourceTable$, dbTest As Database

On Error GoTo whichDB_ERR
Set dbTest = DBEngine(0)(0)
dbpath = Mid(dbTest(strTableName).Connect, InStr(1,
dbTest(strTableName).Connect, "=") + 1)
If dbpath = "" Then
    Set dbTest = CurrentDb()
Else
    Set dbTest = DBEngine(0).OpenDatabase(dbpath)
End If
Set WhichDB = dbTest
whichDB_EXIT:

  Exit Function
  
whichDB_ERR:
  MsgBox Err.Description
  Resume whichDB_EXIT
End Function

-----Original Message-----
From: Gustav Brock [mailto:Gustav at cactus.dk]
Sent: Thursday, January 04, 2007 10:08 AM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] A Question of Timing


Hi Rocky

You could use DAO and the Seek method on this local table if it is indexed
properly.
Seek is extremely fast but the syntax is a bit weird.

/gustav


***********************************************************************
The information transmitted is intended solely for the individual or
entity to which it is addressed and may contain confidential and/or
privileged material. Any review, retransmission, dissemination or
other use of or taking action in reliance upon this information by
persons or entities other than the intended recipient is prohibited.
If you have received this email in error please contact the sender and
delete the material from any computer. As a recipient of this email,
you are responsible for screening its contents and the contents of any
attachments for the presence of viruses. No liability is accepted for
any damages caused by any virus transmitted by this email.


More information about the AccessD mailing list