Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jul 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    added a record to a table (Access 97 SR2)

    I have this code (Below) in a database and I would like to add the voucher# field to another table called IssuedTo with a field name of Voucher#. Is there code I can use to accomplish this. I need to have the data (Voucher#) field saved to the table at this ponit. I'm doing this for a co-worker and this is what they requested. Thanks a bunch!!


    Function AssignMFVoucher()
    Dim dbv As Database
    Dim Vouchers As Recordset
    Dim VouchersTable As String


    VouchersTable = "CashVoucher#"


    Set dbv = DBEngine.Workspaces(0).Databases(0)
    Set Vouchers = dbv.OpenRecordset(VouchersTable)

    On Error GoTo MFAssignError

    MFAssignIt:
    Vouchers.MoveFirst
    AssignMFVoucher = Vouchers("LastVoucher#")

    'Can It be saved to the table at this point? Or before it's deleted?

    Vouchers.Delete
    Exit Function

    MFAssignError:
    Err = 0
    Resume MFAssignIt:

    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: added a record to a table (Access 97 SR2)

    I'd suggest your co-worker stop using symbols in his table and field names. They will bite him sooner or later, probably sooner.

    I'm sorry, but it isn't clear what you're trying to do. Do you want to copy a field's value to another table or do you want to add a field to the other table's design?

    You are retrieving a value from a voucher number field in the CashVouchers table and then deleting that record from the the table. Then do you want to insert the value into a record in another table? Why not just use an append query and then delete the record from CashVouchers that has a matching voucher number?
    Charlotte

  3. #3
    New Lounger
    Join Date
    Jul 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: added a record to a table (Access 97 SR2)

    Thanks Charlotte. Good advice. I was able to get the help I needed from the AddNew examples in help. Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •