Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2015
    Posts
    6

    Unhappy Unanswered: OpenForm command returns error 424: Object required

    Hi all,

    This is probably a simple error, but I'm using the code below to open a form 'Set Detentions' at a given record, using an ID autonumber for each detention (i.e.unique values). This value is contained in the 5th column of the listbox.

    Private Sub List2_DblClick(Cancel As Integer)

    DoCmd.OpenForm "Set Detention", , , "[ID] = " & Me.List2.Column(4).Value

    End Sub
    I double click on a record in the listbox (List 2 (I know - I'll change the name!)) and it returns a 424 error "object required".

    to test the issue, I replaced the last part of the code with ..."[ID] = " & 3, which worked correctly and opened the form at ID number 3, so I figure it's the last part which isn't working?

    Any thoughts? I'm sure it's a really simple error, but I'm still learning!

    Many thanks as always, guys!

    Simt33

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so what is the value of List2.Column(4).Value?

    set a watch / breakpoint OR display the value to a MSGBOX
    prove that there is the value you expect in column 4 of the list box
    bear in mind that, IIRC, the value is base 0, ie Column(4) actually refers to the 5th column in the collection

    i could be he open form macro isn't happy with the form name (ie it can't find the form) or its not happy with a space in the form name. However that error message in this sort of context is usually down to a missing value. hence why you need to check there is a value in List2.Column(4)
    Last edited by healdem; 02-14-16 at 11:26.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Assuming that [ID] is defined as a Number Datatype (which your syntax indicates) the problem, I suspect, is that a given Column...List2.Column(4), in this case...doesn't have a Value Property! A Control has a Value Property...but not a Column in a Control!

    Instead of

    DoCmd.OpenForm "Set Detention", , , "[ID] = " & Me.List2.Column(4).Value

    simply use

    DoCmd.OpenForm "Set Detention", , , "[ID] = " & Me.List2.Column(4)

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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