Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    73

    Question Unanswered: Populate Fields In New Records?

    In the current record, I want a button to poplulate certain fields in a new record from certain fields from the previous one. Cant this be done? Im guessing to use an OnClick event.

    Thanks

  2. #2
    Join Date
    Sep 2004
    Location
    Tampa, FL
    Posts
    520
    Assuming we are talking about in a form wouldn't an append Query on the OnClick do the trick having the query reference the current forms fields for the queries ?

    Darasen
    Darasen

  3. #3
    Join Date
    Nov 2003
    Posts
    1,487
    Well, one way this can be done is to declare Variables (which will be public to the Form only) in the declarations section of your Form, then assign the required values to each variable through the BeforeUpdate or AfterUpdate event for each data field you would like to copy to the next record. For example

    Code:
    Option Compare Database
    Option Explicit
    Dim myCustomerField
    Dim myInvoiceNumberField
     
    '_____________________________________________________
     
    Private MyCustomerName_AfterUpdate ()
       myCustomerField = Me.MyCustomerName
    End Sub
    '_____________________________________________________
     
    Private MyInvoiceNumber_AfterUpdate ()
       myInvoiceNumberField = Me.MyInvoiceNumber
    End Sub
    '_____________________________________________________
     
    Private Sub Form_Current()
       If Me.NewRecord =True Then
    	  Me.MyCustomerName = myCustomerField
    	  Me.MyInvoiceNumber = myInvoiceNumberField
       End If
    End Sub
    There you go... This will now place the data into a new record automatically. If you want to use a button, then forget about the Form_Current routine but place the code contained within it (If/End If) into the OnClick event of your button.


  4. #4
    Join Date
    May 2004
    Posts
    73
    I have never setup an apend query, can someone walk me throught it please?

Posting Permissions

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