PC Review


Reply
Thread Tools Rate Thread

Creating a record in another database

 
 
=?Utf-8?B?RGFuaWVs?=
Guest
Posts: n/a
 
      14th Jun 2004
Hello,

I would like to know how tomodify the following code so that instead of writing to the specified table in the current database it would write the information to an external database c:\delete.mdb containing a table of the same name. I want tomove the table so that is not included as part of the main database.

**********
Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
On Error GoTo Deal_Error:
Dim User As String, Table As String, Record As String, Dwg As String, Issue As String
Dim When As Date

User = CurrentUser()
When = Date
Record = Me.Id
Dwg = Me.Drawing_Number
Issue = Me.Issue
Table = "Drawing History Tbl"

Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("CoordMemo Tbl")
rst.AddNew
rst("Who") = User
rst("When") = When
rst("Table") = Table
rst("Record") = Record
rst("Dwg") = Dwg
rst("Issue") = Issue
rst.Update
rst.Close

Exit_Error:
Exit Sub

Deal_Error:
GoTo Exit_Error

End Sub
***************

Thank you as always,

Daniel
 
Reply With Quote
 
 
 
 
Marshall Barton
Guest
Posts: n/a
 
      14th Jun 2004
Daniel wrote:
>I would like to know how tomodify the following code so that instead of writing to the specified table in the current database it would write the information to an external database c:\delete.mdb containing a table of the same name. I want tomove the table so that is not included as part of the main database.
>
>**********
>Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
>On Error GoTo Deal_Error:
>Dim User As String, Table As String, Record As String, Dwg As String, Issue As String
>Dim When As Date
>
> User = CurrentUser()
> When = Date
> Record = Me.Id
> Dwg = Me.Drawing_Number
> Issue = Me.Issue
> Table = "Drawing History Tbl"
>
>Dim rst As DAO.Recordset
> Set rst = CurrentDb.OpenRecordset("CoordMemo Tbl")
> rst.AddNew
> rst("Who") = User
> rst("When") = When
> rst("Table") = Table
> rst("Record") = Record
> rst("Dwg") = Dwg
> rst("Issue") = Issue
> rst.Update
> rst.Close



Why not just link to the table in the archive mdb file?

If necessary, you can open the recordset on an SQL statement
that uses an IN clause (see Help for details) to specify the
archive MDB file:

strSQL = "SELECT * " _
& "FROM [CoordMemo Tbl] IN ""C:\path\file"" " _
& "WHERE Record = 0"
Set rst = CurrentDb.OpenRecordset(strSQL)

I added the WHERE clause to the query so that you don't
waste time and resources retrieving all the existing records
in the archive file. Check to make sure that I used the
right name for the PK field.
--
Marsh
MVP [MS Access]
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a new record on a form where its' record source is a Quer =?Utf-8?B?dHRfR3lybA==?= Microsoft Access Forms 1 27th Aug 2007 04:23 PM
Main form is creating new record for each record in subform... =?Utf-8?B?RE1M?= Microsoft Access Forms 0 5th Oct 2004 08:25 PM
Creating a new record from selected fields of existing record =?Utf-8?B?U3Vl?= Microsoft Access 4 6th May 2004 04:53 PM
Creating a new record from selected fields of existing record Sue Microsoft Access Forms 3 6th May 2004 04:20 PM
Updating a record source of a combo box after creating a new record CQMMAN Microsoft Access 1 16th Dec 2003 07:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:30 AM.