Results 1 to 4 of 4
  1. #1
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365

    Passing TextBox Name gives error 424 Object required

    The code is in a Pop-up form on top of frmShowRecord and is is giving Object required error
    Code:
    Form_frmShowRecord.TurnOrange (Form_frmShowRecord!txtATime)
    And in frmShowRecord where txtATime is the name of the textbox control


    Code:
    Public Sub TurnOrange(t As TextBox)
        Stop
    End Sub
    How do I pass the textbox to the subroutine

  2. #2
    madpiet is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    154
    Quote Originally Posted by Middlemarch View Post
    The code is in a Pop-up form on top of frmShowRecord and is is giving Object required error
    Code:
    Form_frmShowRecord.TurnOrange (Form_frmShowRecord!txtATime)
    And in frmShowRecord where txtATime is the name of the textbox control
    Code:
    Public Sub TurnOrange(t As TextBox)
        Stop
    End Sub
    How do I pass the textbox to the subroutine
    Wouldn't it just be

    Call turnOrange Forms!MyOpenForm!txtMyTextbox

    ?

    basically, you have to tell the code *which* textbox (on which form) when you call it. If the textbox is on the form you're calling the subroutine from, you could use Call turnOrange me!txtMyTextBox

  3. #3
    Edgar is online now Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    Just remove the parentheses:
    Code:
    Form_frmShowRecord.TurnOrange Form_frmShowRecord!txtATime
    You don't need them if you're just calling the Sub. It is asking you for an object because when you use the parentheses, you're supposed to be making an assignation like this:

    Code:
    Set SomeObjectVariable = Form_frmShowRecord.TurnOrange(Form_frmShowRecord!txtATime)
    By the way, when using Form_ for your references, favor not using the bang ! and use dot . instead, that way you'll get nice intellisense for that form. Less guessing = less pain.
    Please click on the ⭐ below if this post helped you.


  4. #4
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365
    The Form calling the subroutine is not the Form the textbox is in.
    But thanks for the reply as adding "Call" to the instruction worked !

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

Similar Threads

  1. Object required error 424
    By GraeagleBill in forum Programming
    Replies: 5
    Last Post: 06-22-2018, 12:00 PM
  2. Error Object required: Please help
    By lccrews in forum Programming
    Replies: 1
    Last Post: 06-14-2018, 10:59 AM
  3. Object Required Error
    By sgp667 in forum Programming
    Replies: 1
    Last Post: 11-06-2012, 03:15 AM
  4. Error: Object Required
    By compooper in forum Programming
    Replies: 6
    Last Post: 06-22-2011, 07:52 AM
  5. Object Required Error.
    By Robeen in forum Forms
    Replies: 1
    Last Post: 03-28-2011, 10:30 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