Why am i getting run time error code 424 - Object Required?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Clueless24
    New Member
    • May 2010
    • 1

    Why am i getting run time error code 424 - Object Required?

    Hi,

    I am really new to writing code and am trying to do a simple lookup on a form in access but when i run it i keep getting the run time error code '424' which says 'Object is required'.

    The code i have written is as follows:

    Private Sub Combo21_AfterUp date()

    If (Combo37 = qry_TasksStatus Test.Task) Then Text24 = qry_TasksStatus Test.Resource

    End Sub

    Can anyone help please?

    Thanks
    Sam
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi Sam. You are referring to properties of an 'object' called qry_TasksStatus Test in your IF statement, which the Access VBA interpreter is unable to find. I doubt that it is a valid 'object' for Visual Basic for Applications at all.

    I guess the two properties you are referring to, Task and Resource, are fields in a query called qry_TasksStatus Test that you really want to look up.

    If the query is the record source of your form you should already have controls on your form which are bound to these two fields. If you have not included these two fields you can use the forms designer to add them. You could then refer to their current values using the shortcut notation of 'Me.' to refer to that control on the current form, as in

    Me.Task and Me.Resource

    If, as I suspect is really the case, the fields are from a separate query which is not currently the recordsource of your form you cannot run it or get field values back from it by using the syntax queryname.field - this simply will not work. You would need to use the Dlookup function to return the value for a specific field given some condition to apply to your data. Rather than go over the syntax for this at present I would suggest you rethink what it is you are trying to achieve first. I'm sure we can help you achieve your aims, but if you could expand a bit on what you are trying to do it would help us a lot.

    Welcome to Bytes!

    -Stewart

    Comment

    Working...