DarrenBoyer
IS-IT--Management
I have found some code that helps me to create a custom Autonumber from the Access 2002 Developer Series books. However, I don't like or understand why the authors have the Counting Table in another database.
I'm concerned this issue may cause me problems down the road, plus I should learn more about my solution anyways.
Here are the code excerpts that ask for the Counting Table outside the database.
1st off they declare the other database as a constant
[blue]Const adhcAutoNumDb = "MultiuserTrial" [/blue]
My terminology may be poor but next they perform the standard DAO setup
[blue]Dim wrk As DAO.Workspace [/blue]
Dim db As DAO.Database
Dim rstAutoNum As DAO.Recordset
Dim lngNextAutoNum As Long
Dim lngW As Long
Dim lngX As Long
Dim intRetryCount As Integer
Randomize
DoCmd.Hourglass True
intRetryCount = 0
' Open a recordset on the appropriate table in the
' autonumbers database denying all reads to others
' while it is open
[blue]Set wrk = DAO.DBEngine.Workspaces(0)
Set db = wrk.OpenDatabase(adhCurrentDBPath() & adhcAutoNumDb, False)[/blue]
Set rstAutoNum = db.OpenRecordset("tblCounter", _
dbOpenTable, dbDenyRead)
adhCurrentDBPath is a procedure that 'references' the other database with my Custom Counter table. I didn't include the code because in my limited understanding of DAO I don't expect any soultion would have to reference the filepath of another database. It seems I need to change the object I'm working with from a Workspace to a recordset but all attempts have come to failure.
My Counting Table is also called tblCounter in my main database and the Counting Field is called NextAvailableCounter.
If someone could post a suggestion or sample solution I would really appreciate it.
I'm concerned this issue may cause me problems down the road, plus I should learn more about my solution anyways.
Here are the code excerpts that ask for the Counting Table outside the database.
1st off they declare the other database as a constant
[blue]Const adhcAutoNumDb = "MultiuserTrial" [/blue]
My terminology may be poor but next they perform the standard DAO setup
[blue]Dim wrk As DAO.Workspace [/blue]
Dim db As DAO.Database
Dim rstAutoNum As DAO.Recordset
Dim lngNextAutoNum As Long
Dim lngW As Long
Dim lngX As Long
Dim intRetryCount As Integer
Randomize
DoCmd.Hourglass True
intRetryCount = 0
' Open a recordset on the appropriate table in the
' autonumbers database denying all reads to others
' while it is open
[blue]Set wrk = DAO.DBEngine.Workspaces(0)
Set db = wrk.OpenDatabase(adhCurrentDBPath() & adhcAutoNumDb, False)[/blue]
Set rstAutoNum = db.OpenRecordset("tblCounter", _
dbOpenTable, dbDenyRead)
adhCurrentDBPath is a procedure that 'references' the other database with my Custom Counter table. I didn't include the code because in my limited understanding of DAO I don't expect any soultion would have to reference the filepath of another database. It seems I need to change the object I'm working with from a Workspace to a recordset but all attempts have come to failure.
My Counting Table is also called tblCounter in my main database and the Counting Field is called NextAvailableCounter.
If someone could post a suggestion or sample solution I would really appreciate it.