Subform issue

G

Guest

Hi there...

I've tried to set a filter on a sub form by clicking a calendar button on my
main form. I even copied my old version so I knew I had the text correctly,
but now, I seem to be getting an error as follows:

Run-time error '-2146500594 (800f00e)':
Method 'Form' of Object' _SubForm' Failed

I've had this work in the past, but for some reason (which I can't figure
out) it's giving me an error. The coding on the OnClick of the calendar
control I'm using is as follows:

Forms!frmMainMenu!frmReadings.Form.Filter = "Date=#" & Me.AcXCalendar.Value
& "#"

Any help would be wonderful.

Thanks in advance!!
 
K

Ken Snell \(MVP\)

I assume that frmReadings is the name of the form that is the Source Object
for the subform control.

You must use the name of the subform control in place of frmReadings. The
name of the subform control is found by opening the main form in design
view, clicking on the top boundary of the subform control, opening the
Properties window, and clicking on the Other tab to read the Name property.
 
G

Guest

I checked that out as well. It happens to be the same name. Do I need to
change that?

Sorry...I should have clarified before as well:
frmMainMenu is my main form with the calendar control on it
frmReadings is my subform which I am trying to apply the filter to.

I tried to change the name of the subform but I still got the same error.

Sorry to be a bother!
 
K

Ken Snell \(MVP\)

Does your code also set the ApplyFilter property to True after you set the
Filter property? It's a two-step operation -- Filter sets the string to use
as the Filter, ApplyFilter turns the filter on and off (True and False).
 
G

Guest

Thanks for your on-going support Ken!!

Yes, the second portion of my code turns the filter value using the same
string:

Forms!frmMainMenu!frmReadings.Form.FilterOn = True

However, the code never gets to that point as it fails on the line before it.

I'm sure it's something simple that I'm not doing correctly, I just can't
figure out what it is!!

Thanks again!
 
G

Guest

This was starting to drive me crazy so I re-built a "test" subform and tried
linking it to the same frmMainMenu. I used the exact same logic and the same
syntax to write my code and for some reason, it now works.

I'd still like to know why the original form didn't work, but at least I can
continue on with my progress. I have kept both forms in case you have a
solution for me.

Thanks again!
 
K

Ken Snell \(MVP\)

Hard to say, although subtle corruptions can creep into a form during
design/development. Personally, I'd delete the nonworking form and keep
going with the working form.
 
G

Guest

Thanks for taking the time to look into this for me Ken.

Sorry it was a wasted effort!
TT
 

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

Top