Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002
    Posts
    157

    Unanswered: Event Procedure for subform

    Hi there, I hope someone can help me.

    I have a form called Employer Request Form

    On this form I have a Tab Control called Employer Requests

    On this Tab Page I have a subform called usysOpen Requests

    On the Employer Request form I have four text boxes called (yes there are spaces between the names):
    Org Contact Name
    Org Contact Phone
    Org Contact Fax
    Org Contact Email

    On the usysOpen Requests form I have four text boxes called (there are no spaces between the names):
    SuperContactName
    SuperContactPhone
    SuperContactFax
    SuperContactEmail

    At first all I wanted to do was to create an [Event Procedure] whereby after updating the Org Contact Name text box, the same detail populated the SuperContactName text box (on the sub form).

    This was to continue with the phone, fax and email text boxes.

    I tried the following code but on testing, I get this error message “Run-time error’2450’ Microsoft Access can’t find the form ‘usysOpen Requests’ referred to in a macro expression or Visual Basic code.

    Private Sub Org_Contact_Name_AfterUpdate()
    Forms![ usysOpen Requests].ctlSubForm!SuperContactName.Value = Forms![Employer Request Form]![Org Contact Name].Value
    End Sub

    Can anyone advise what I am doing wrong. (note I have tried this code with and without .ctlSubForm

    I have since thought that once I get the above to work, I should also add another piece of code to do the following:
    Check if there is any detail in the subform SuperContactName text box. If there is, then nothing is to happen. If there is no detail then the information in the Org Contact Name text box is to populate the subform SuperContactName text box.

    Can anyone help with this piece of code?

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi Karen

    I always forget how to refer to subforms too. The sytax is:
    Code:
    Forms![ParentFormName]![SubFormObjectName].Form.[ControlNameOnSubForm]
    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    May 2002
    Posts
    157

    Event Procedure for subform

    Wow it is easy when you know how. Thanks so much.

    The following code works:
    Forms![Employer Request Form]![usysOpen Requests].Form.[SuperContactName].Value = Forms![Employer Request Form]![Org Contact Name].Value


    Now all I have to do is create code to work with the above that checks
    if there is any detail in the subform SuperContactName text box. If there is, then nothing is to happen. If there is no detail then the information in the Org Contact Name text box is to populate the subform SuperContactName text box.

    Wow that was easy. The answer is:

    Private Sub Org_Contact_Name_AfterUpdate()

    If IsNull(Forms![Employer Request Form]![usysOpen Requests].Form.[SuperContactName].Value) Then
    Forms![Employer Request Form]![usysOpen Requests].Form.[SuperContactName].Value = Forms![Employer Request Form]![Org Contact Name].Value
    End If

    End Sub
    Last edited by Karen Day; 09-01-06 at 12:56.

Posting Permissions

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