Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917

    I'll see what I can put together for you.

  2. #17
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Copy the following to a Standard Module named basTempTable
    Code:
    Option Compare Database
    Option Explicit
    '-- You can change these to match your names
    Const MyTempDB As String = "MyTemp.mdb"
    Const MyTable As String = "tmpTransactions"
    '-- The next name is the name of the copy of your tblTransactions table
    '-- that you have manually copied to another name and deleted all of the records and any AutoNumber field.
    Const MyStructure As String = "StructureTransactions"
    '  This is designed for Access 2003 or before
    Public Sub CreateTempDB()
    '   Create a temporary external mdb on the local disk so we can kill it later
    '   ...and avoid the bloat that MS Access has been known to exibit.
    
       On Error GoTo Err_CreateTempDB
       Dim Directory As String
       Dim db As DAO.Database
       Dim dbNew As DAO.Database
       Dim tbl As TableDef
       Set db = CurrentDb()
       '-- Remove the link reference to the Temp table if it exists.
       db.TableDefs.Delete "tmpTransactions"
       '-- Create the string for the path where this program resides.
       Directory = CurrentProject.Path & "\"
       '-- Delete the old TempDB, if it exists.
       If Dir(Directory & MyTempDB) <> vbNullString Then
          Kill Directory & MyTempDB
       End If
       '-- Now create the external new mdb file
       Set dbNew = CreateDatabase(Directory & MyTempDB, dbLangGeneral)
       dbNew.Close
       '-- Copy the local table STRUCTURE to our new temporary database
       '--    This Structure has no records and NO AutoNumber field
       DoCmd.CopyObject Directory & MyTempDB, MyTable, acTable, MyStructure
       '-- Attach the tables from the newly created database
       Set tbl = db.CreateTableDef(MyTable)
       tbl.Connect = (";DATABASE=" & Directory & MyTempDB)
       tbl.SourceTableName = MyTable
       '-- Now add this table as a linked table
       db.TableDefs.Append tbl
       db.Close
    Exit_CreateTempDB:
       If Not tbl Is Nothing Then
          Set tbl = Nothing
       End If
       If Not db Is Nothing Then
          db.Close
          Set db = Nothing
       End If
       If Not dbNew Is Nothing Then
          Set dbNew = Nothing
       End If
       Exit Sub
    Err_CreateTempDB:
       If Err.Number = 53 Then          '-- File not found
          Resume Next
       ElseIf Err.Number = 3265 Then    '-- Referenced object does not exist in this collection
          Resume Next
       ElseIf Err.Number = 75 Then      '-- Path/File access error
          Resume Next
       Else
          MsgBox "Error No:    " & Err.Number & vbCr & _
                 "Description: " & Err.Description
          Resume Exit_CreateTempDB
       End If
    End Sub
    Public Sub DestroyTempDB()
       On Error GoTo Err_DestroyTempDB
       Dim db As DAO.Database
       Set db = CurrentDb()
       '   Remove the reference to the linked table
       db.TableDefs.Delete MyTable
       '   Delete the created mdb file
       Kill CurrentProject.Path & "\" & MyTempDB
    Exit_DestroyTempDB:
       If Not db Is Nothing Then
          db.Close
          Set db = Nothing
       End If
       Exit Sub
    Err_DestroyTempDB:
       If Err.Number = 53 Then          '-- File not found
          Resume Next
       ElseIf Err.Number = 3265 Then    '-- Referenced object does not exist in this collection
          Resume Next
       ElseIf Err.Number = 75 Then      '-- Path/File access error
          Resume Next
       Else
          MsgBox "Error No:    " & Err.Number & vbCr & _
                 "Description: " & Err.Description
          Resume Exit_DestroyTempDB
       End If
    End Sub
    Public Sub UpdateFromTempDB()
    '-- Update the local table from the Temp table if there are any records
       CurrentDb.Execute "Update tblTransactions FROM MyTable"
    End Sub
    Let me know if you need additional help. I put some notes at the top of the code.

  3. #18
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    It is pretty simple from here but I'd be glad to help.

  4. #19
    Nixx1401 is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Feb 2010
    Location
    Barbados
    Posts
    115
    Where exactly am I placing this code. Please walk me through

  5. #20
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Create a new Standard Module named basTempTable and put *all* of the code in it.

  6. #21
    Nixx1401 is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Feb 2010
    Location
    Barbados
    Posts
    115
    Hi There,

    It been a while since I visited this thread because work tasks did not permit me. I am going to attached the db. I copied the code for the module but dont know what else to do. Can you please assist.
    Last edited by Nixx1401; 05-24-2011 at 10:41 AM.

  7. #22
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    I should have time today to look at it.

  8. #23
    Nixx1401 is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Feb 2010
    Location
    Barbados
    Posts
    115
    Hi

    I realize that I did not attach the db. I have done so now can you please look at the db for me please

  9. #24
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    I should have some time today.

  10. #25
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    The Lookup ComboBox complicates things. Is it important the user see previous entries?

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 05-04-2011, 06:17 PM
  2. Replies: 1
    Last Post: 11-25-2010, 11:00 AM
  3. Replies: 1
    Last Post: 10-13-2010, 12:40 PM
  4. Locking Records in Subform
    By MuskokaMad in forum Forms
    Replies: 1
    Last Post: 04-02-2010, 06:34 PM
  5. Find data, load data, and save as a new record
    By hawzmolly in forum Access
    Replies: 0
    Last Post: 10-05-2008, 03:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums