422,023 Members | 1,004 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,023 IT Pros & Developers. It's quick & easy.

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

P: 1
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_AfterUpdate()

If (Combo37 = qry_TasksStatusTest.Task) Then Text24 = qry_TasksStatusTest.Resource

End Sub

Can anyone help please?

Thanks
Sam
May 20 '10 #1
Share this Question
Share on Google+
1 Reply


Expert Mod 2.5K+
P: 2,545
Hi Sam. You are referring to properties of an 'object' called qry_TasksStatusTest 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_TasksStatusTest 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
May 21 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.