Results 1 to 2 of 2
  1. #1
    Join Date
    May 2002
    Posts
    37

    Unanswered: ...Calling a procedure from a subform...Part 2

    OK, this works fine...
    Until I set the focus on x, x is a textbox on a subform.

    Then I get Run-time error '424'
    Object Required

    Any thoughts?


    <Code>
    Public Function pft_asr_check_blanks()
    Dim x
    x = Forms![frm_ent_pft_asr]![frm_ent_pft_asr_sub]![pft_asr_ee_revper]

    If IsNull(x) = True Or x = "" Then
    'Error Occurs Below
    x.SetFocus
    MsgBox "Please specifiy a review period."
    End
    End If
    End Function

  2. #2
    Join Date
    May 2002
    Location
    Atlanta, GA
    Posts
    117
    I have an idea,

    I'm not sure why you are using a Public Function, its not necessary. All you have to do is the following:

    Lets name our Main form "Form1"
    and our Sub Form "Form2"
    and our Field on Form2 "Field1".

    From the main form:

    Private Sub Command_Click()

    If IsNull(Forms!Form1!Form2!Field1) Then
    MsgBox"Please enter data!"
    Me.Form2.SetFocus
    Me.Form2!Field1.SetFocus
    Exit Sub
    Else
    Do Some Kind of Command
    End If
    Exit Sub

    Just make sure you set the focus to the Sub Form before trying to set the focus to one of its fields..

    Let me know if this helps
    Kal

Posting Permissions

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