SubForm Record Source (1 Viewer)

kirkm

Registered User.
Local time
Tomorrow, 00:00
Joined
Oct 30, 2008
Messages
1,257
Colin the subform control and Subform itself confuses me! I still don't get that. But if the subform has a Current event, where or how to I find it to put some code there?


Adam by "click every record" the subform is datasheet view and it's as a row is clicked on or you move to the next record, then the data in that row is what the other subform should show. Well, not exactly the same, but a query built from the data in that row.



One other thing no-one replied to, the font used (Calibri?) - can I change that? I'd like to use MS san serif size 6 as it shows (fits) more on the screen.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:00
Joined
Oct 29, 2018
Messages
21,449
Colin the subform control and Subform itself confuses me! I still don't get that. But if the subform has a Current event, where or how to I find it to put some code there?

Adam by "click every record" the subform is datasheet view and it's as a row is clicked on or you move to the next record, then the data in that row is what the other subform should show. Well, not exactly the same, but a query built from the data in that row.

One other thing no-one replied to, the font used (Calibri?) - can I change that? I'd like to use MS san serif size 6 as it shows (fits) more on the screen.
Hi. Pardon me for jumping in but please see if there anything in this article to help clarify some of your confusions. Hope it helps...
 

vba_php

Forum Troll
Local time
Today, 07:00
Joined
Oct 6, 2019
Messages
2,880
Colin the subform control and Subform itself confuses me! I still don't get that. But if the subform has a Current event, where or how to I find it to put some code there?
see images.... ;)
One other thing no-one replied to, the font used (Calibri?) - can I change that? I'd like to use MS san serif size 6 as it shows (fits) more on the screen.
I have no idea, but I would guess not. font types and sizes are connected to controls and objects closer to the interface level of the application rather than the "data" level of the app. that makes sense to me. ask Colin though, he'll know.
Hi. Pardon me for jumping in but please see if there anything in this article to help clarify some of your confusions. Hope it helps...
that's bob larson's article! Have you talked to him since he vanished from here, guy?
 

Attachments

  • subform_object_has_current_event.jpg
    subform_object_has_current_event.jpg
    101 KB · Views: 104
  • subform_control_only_has_2_events.jpg
    subform_control_only_has_2_events.jpg
    99.3 KB · Views: 102

kirkm

Registered User.
Local time
Tomorrow, 00:00
Joined
Oct 30, 2008
Messages
1,257
Don't know why this pizzles me so much, but it just does. I understand you have a Form and you put a control on it. Period. Anything esle justy confuses.

But I found it Adam, thank you and I think it's work if I can code this
Code:
Me.[TheRun].Form.RecordSource = sq2
which works in a button on the Main Form but I've tried a zillion things in the sunForms _Current event and nothing works so far.


If you can't set a Font why is it provided as Property??
 

vba_php

Forum Troll
Local time
Today, 07:00
Joined
Oct 6, 2019
Messages
2,880
it's work if I can code this
Code:
Me.[TheRun].Form.RecordSource = sq2
which works in a button on the Main Form but I've tried a zillion things in the sunForms _Current event and nothing works so far.
i'm not sure. I'll have to test it to find out because the answer just doesn't come to mind. I'll run a test just for fun, but before I get back to you someone else might give the answer anyway.
If you can't set a Font why is it provided as Property??
no idea. but don't always listen to what I say. a lot of times in my rambling, the obvious and simple solution is sometimes overlooked and everyone on this forum knows that by now. I'm more of a back-end, lower level person when it comes to technology, so the higher-level stuff that's closer to the interface part of applications (e.g. - what "button clickers" use) sometimes slips through the cracks with me.
 

vba_php

Forum Troll
Local time
Today, 07:00
Joined
Oct 6, 2019
Messages
2,880
Kirk,

Hopefully the mods don't get mad at me for this, but if you want a real good look at how complex subforms can get, nothing could possibly be more complicated than Larry Ellison's creation with Oracle's massive use of forms. And you think Access is though? :p check this out:

https://docs.oracle.com/cd/E17984_01/doc.898/e14706/subform_aliases.htm

I'll run a test on your last issue and post an answer if I can find one, regardless if someone else gives you an answer or not. We're almost done with the final stretch!
 

kirkm

Registered User.
Local time
Tomorrow, 00:00
Joined
Oct 30, 2008
Messages
1,257
Adam I figured it out
Code:
Me.Parent.[TheRun].Form.RecordSource = sq2
But there's another issue "nn=Me!Number" is giving an error
Run-time error '2424':
The expression you entered has a field, control, or property name that
Microsoft Access can't find.

But it trap it out with On error Resume next, everything works perfectly. Maybe the OnCurrent event is running before Number exists ? Would that cause it?
 

vba_php

Forum Troll
Local time
Today, 07:00
Joined
Oct 6, 2019
Messages
2,880
But there's another issue "nn=Me!Number" is giving an error
Run-time error '2424':
The expression you entered has a field, control, or property name that
Microsoft Access can't find.

But it trap it out with On error Resume next, everything works perfectly. Maybe the OnCurrent event is running before Number exists ? Would that cause it?
it's hard to say man. some of the language you're using in your posts can't really be deciphered properly because no one has actually seen what you're working with. stuff like running before Number exists doesn't make much sense to me because I have no idea what, where, or under the circumstance "number" came from. you see? but regarding this:
Code:
"nn=Me!Number" is giving an error
more than likely that's an error because *nn* is a field and you're trying to assign a control value referenced by Me!Number *inside* double quote marks. that's a no no. if everything I've said is true, you need to do this:
Code:
"nn=" & Me!Number
you can google the reason why. that's basic ms access knowledge.
 

kirkm

Registered User.
Local time
Tomorrow, 00:00
Joined
Oct 30, 2008
Messages
1,257
The error only happens once, when the form opens or runs first. After that it's fine. Number is a field name. I suspect the On Current event is running before "Number" is created. So let me cobble it into a presentable state and upload it. It would be worth knowing these things and maybe there's better methods than I've used. But may take me an hour or so.
 

vba_php

Forum Troll
Local time
Today, 07:00
Joined
Oct 6, 2019
Messages
2,880
I suspect the On Current event is running before "Number" is created.
when i ran a test on the forms, I noticed that the current() event was happening before the form was showing itself on the screen. so yes, in a sense, it sounds like you're right. I've never known the exact fire order of form events, and I never bothered to research it. You're not technically correct though regarding the language you're using, but that's something semantical for professionals to argue I would say. we'll wait for you to upload what you've got....
 

kirkm

Registered User.
Local time
Tomorrow, 00:00
Joined
Oct 30, 2008
Messages
1,257
Form6 is opening Form and a click in the bottom Form should show an output from that in the Middle Form.
 

Attachments

  • Build12a.zip
    130.2 KB · Views: 122

Micron

AWF VIP
Local time
Today, 08:00
Joined
Oct 20, 2018
Messages
3,478
Kirkm, maybe this will help with some of your confusion. As you know, a form contains controls. Those controls may or may not be bound to tables or queries but regardless, what they hold is data. A subform control is just another type of control. Instead of holding data, it holds another form. One other thing worthy of note when using subforms on forms is that a subform loads first, then the main form. When closing all, the main form unloads first, then the subform.

If opening a main form that contains a subform and you attempt to retrieve a value from a main form, or try to do anything TO it FROM the subform when these forms are opening, that will fail.

If you use a form wizard or simply drag a form onto a main form, Access will seamlessly place the subform in a subform control and will give it the same name as the form (which I find regrettable). While in design view, if you click on the subform first, it is the subform control that will hilight and you can review its properties in the property sheet . Click the form a second time and it is the subform itself that will become the selected object.

Hope some of that helps.
 

vba_php

Forum Troll
Local time
Today, 07:00
Joined
Oct 6, 2019
Messages
2,880
Kirk,

the test I ran showed that the current event was trying to fire before the form could appear, and thus before it could load. the answer thus probably lies in what Micron told you. so I doubt it's possible to do what you want to do. I'm showing you the working solution by putting the button called run test here on the main form. click it and you'll see what you want to have happen. if indeed micron is right, then you'll have to settle for a workaround. I also put code behind the qryEachWeek subform control's number field and that field's double click event that does the same thing as clicking the button does when you double click inside that number field on your datasheet. maybe you can use that method instead?
 

Attachments

  • Build12a - issue resolved.zip
    161.1 KB · Views: 129

kirkm

Registered User.
Local time
Tomorrow, 00:00
Joined
Oct 30, 2008
Messages
1,257
Hi Micron, are you saying a subForm control isn't a subForm but contains a subForm ?
I think i am doing what you describe, hence the erorr when it opens and okay the next / subsequent times. Maybe someone will confirm that and there's a better solution, although the on-error lets it work.



Yes, very true where/what/how many clicks on various bits drives me batty.. of course I never do it enough to ever really get used to it. Getting something working can be a bit of a mission. Then 6 months later you've forgotten and have to do it all again.

Right now my "TheDate" column isn't wide enough, so I drag it wider, Save, close and it's reverted back to being too narrow. So you do it again... and again...
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 08:00
Joined
May 21, 2018
Messages
8,525
are you saying a subForm control isn't a subForm but contains a subForm
The subform control is the picture frame. The source object is the picture inside the picture frame which is usually a another form but can be query/table datasheet.
 

Micron

AWF VIP
Local time
Today, 08:00
Joined
Oct 20, 2018
Messages
3,478
The subform control is the picture frame. The source object is the picture inside the picture frame which is usually a another form but can be query/table datasheet.
That's an interesting way of putting it - I'll have to remember that one.
are you saying a subForm control isn't a subForm but contains a subForm ?
I take it that you now have clarity on that question. When writing responses some will use the word "subform" when they ought to be referring to the control itself so keep that in mind.
 

kirkm

Registered User.
Local time
Tomorrow, 00:00
Joined
Oct 30, 2008
Messages
1,257
Yes I think so Micron. Thanks to everyone for the info/help and Adam for your changes.
 

vba_php

Forum Troll
Local time
Today, 07:00
Joined
Oct 6, 2019
Messages
2,880
mark the thread solved if the day is over kirk.
 

Users who are viewing this thread

Top Bottom