Results 1 to 1 of 1
  1. #1
    Join Date
    Sep 2008
    Posts
    12

    how to copy data

    I created a form that displays fields from multiple tables. The thing common in each table is an EmployeeID field. The EMPLOYEES table auto generates a value for the EmployeeID field and on the form I need to copy that value into two other textfields on the form when it is generated.

    So, if you follow me, the EMPLOYEE_STATS table has an EMPLOYEE_ID field and so does the LOCATION table have an EMPLOYEE_ID field. The relationship is 1 to 1 from table EMPLOYEES to both EMPLOYEE_STATS and LOCATION tables.

    How do I copy the EMPLOYEE_ID to the same two labelled textfields on the form? I'm assuming I must use VBA to do this but require instruction. I tried noodling around with it, but came across a very frustratiing restriction in VBA. It seems to have a rule that you can't reference other objects on the form because they currently don't have the focus. How crummy is that? There must be a way around that!

    So then I decided to create a Module with the following subroutine in it:

    Public Sub COPY_EMPLOYEE_ID(field As TextBox)
    Dim id As String
    id = Form_EMPLOYEES.EMPLOYEES_EMPLOYEE_ID.Text
    field.Text = id


    End Sub

    And from the EMPLOYEE_STATS_EMPLOYEE_ID_GotFocus() event method I wrote:

    Private Sub EMPLOYEE_STATS_EMPLOYEE_ID_GotFocus()
    Module1.COPY_EMPLOYEE_ID (Form_EMPLOYEES.EMPLOYEE_STATS_EMPLOYEE_ID)
    End Sub

    Once again I'm foiled by Access. I keep getting an error message from the one line in the GotFocus method stating: Runtime Error 424 Object Required.
    Well hell! I can't be more specific than that!

    Please advise,

    Alan
    Last edited by ashiers; 09-19-2008 at 04:22 PM. Reason: Original problem solved. Now have new problem.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Displaying a picture on a form
    By kydbmaster in forum Forms
    Replies: 4
    Last Post: 04-04-2009, 07:54 PM
  2. Displaying Query Properties in a Form
    By Bjar in forum Programming
    Replies: 1
    Last Post: 07-16-2008, 07:51 AM
  3. Replies: 1
    Last Post: 10-26-2007, 07:29 AM
  4. Displaying a PDF in a Form
    By Chaz in forum Forms
    Replies: 0
    Last Post: 08-07-2006, 03:26 PM
  5. Form field not displaying in query
    By Valeda in forum Queries
    Replies: 2
    Last Post: 05-05-2006, 10:08 AM

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