Addressing subform field in Where clause

andrefrancis

andrefrancis
Local time
Yesterday, 18:53
Joined
Mar 11, 2005
Messages
40
I am trying to address a subform field.

If I address the subform as a separate form, the following code works OK
DoCmd.OpenForm frmSessions, , , "Issue = true" :)

However, once I try to access it as a subform, I get a bit lost.
The main form is frmJobSess, the control that holds the subform is Sessions and the subform is (as above) frmSessions.

I have tried:
DoCmd.OpenForm frmJobSess, , , "Sessions.frmSessions.Issue = true"
but it doesn't work. :(. I have also tried other things ... but there is not enough time in the world to try all possible combinations :eek:

Should I be using exclamation marks? I know I don't need square brackets since all my names are without spaces.

Can anyone help?
 
Andre

If you do a search on this you will find lots of threads on this topic.

An example from a recent project of mine is

Forms!frmCreateInvoice!sfrmInvoiceDetail.Form!txtEngineerCode = strEngineerCode

the .form after the subform name is vital the choice of "!" or "." is less so
 
jgc31 said:
Andre

If you do a search on this you will find lots of threads on this topic.

An example from a recent project of mine is

Forms!frmCreateInvoice!sfrmInvoiceDetail.Form!txtEngineerCode = strEngineerCode

the .form after the subform name is vital the choice of "!" or "." is less so

Thanks jgc ... I will try again shortly

Incidentally, in your code above, I can see a form and a subform but no control between ... is this OK?
 
I'm a little at loss at what you're trying to achieve.

You can open a form as a form

You cannot "open a subform", you open the main form on which the subform resides.

If the issue is that you whish to filter the subform, I don't think you can use the wherecondition (wich applies to the main form).

One thing to try, if this is a dynamic criterion, is to store the value in a public variable prior to opening the form/subform thingie, then in the on load/open event of the subform, set a filter

me.filter = "session = " & gfMyPublic
me.filteron=true

Don't know how this will work, though, if you have some link master/child thingies set up.
 
Yes, Roy ... I need to filter the records of the subform (in the same defined way) each time I select a different record from the main form. You have now got me thinking ... and I am sure you're correct that the filter is only OK for a main form.

I think I will try defining a query that filters the records as I require, and then base a copy of the original subform on this query via a new form/subform pair.

I think this is in the spirit of what you suggest. I will try to report back (if anyone is interested :o ). Thank you for your comment Roy.

Has anyone got any other suggestions?
 

Users who are viewing this thread

Back
Top Bottom