Run-Time error 438

  • Thread starter Thread starter bw
  • Start date Start date
B

bw

I'm getting...
'Run-Time error 438':
Object doesn't support this property or method
in the procedure below.

The current form is frmHotels.
I want the Hotel location to be sorted each time a new Hotel is selected.
Can someone explain what's wrong?

Private Sub Form_Current()
Forms!MakeTravelRequest!frmHotels!frmHotelLocationsSubform1.OrderBy =
"Lookup_LocationID.Location"
End Sub

Thanks,
Bernie
 
Assuming that frmHotels is the name of the subform container on form
MakeTravelRequest, and frmHotelLocationsSubform1 is the name of the subform
container on form frmHotels, try:

Forms!MakeTravelRequest!frmHotels.Form!frmHotelLocationsSubform1.Form.OrderB
y = "Lookup_LocationID.Location"

Note that the name of the subform container is not necessarily the name of
the form being used as a subform. If you created the subform by dragging the
form onto the parent form, the subform container will usually be the same as
the form's name. However, if you created the subform by adding a subform
control from the Tool Box and then populated its values (whether you used
the wizard or not), the subform container will be named something like
Child0.

Checkout http://www.mvps.org/access/forms/frm0031.htm at "The Access Web"
for a good overview of how to refer to forms and subforms.
 
Thanks Douglas, your code worked (no error message), but the code is not
doing what I want.

I'm not sure how to "show" you the Form, but I'll try to describe it.
frmHotelLocationsSubform1 is a Datasheet. When I look at each Hotel, I want
the locations to be sorted for that Hotel, but they are not.
If I look at frmHotelLocationsSubform1 by itself, all locations ARE sorted
correctly.

Got an idea what my be the problem? If you need more information please
don't hesitate to ask.
Bernie
 
You sure Lookup_LocationID.Location is the correct field to sort by? You
didn't happen to use a lookup field did you?
 
Well, no, I don't know if I'm sorting by the right field. If I click
anywhere in the form where the locations are located, and then click on the
"Sort Ascending" button on the tool bar, then everything is as it should be,
and stays that way no matter which hotel I choose..

So how do I show you if I'm sorting on the correct field?

Bernie
 
What's the RecordSource for your form?

Ideally, it should be a query that sorts the data in the order you want, and
then you won't have to worry about setting the OrderBy property.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top