skiller
New member
- Local time
- Today, 02:57
- Joined
- Nov 6, 2022
- Messages
- 9
Hi,
I'm fairly new to Access programming and, despite being very familiar with the syntax of VB/VBA, the behaviour of the Access data-bound forms can sometimes be quite alien to me.
I can go into the details of my particular coding "challenge" if asked, but I think my problem can be brought down to the following question:
Why does the current record change back to the first record after a particular resize of the form?
To elaborate, if I have a form which has a "Continuous Forms"-style view of its records, then I don't want the currently selected record to change simply because the form has been resized. But it seems to do exactly that - the focus moves back to the first record.
I've tried to pin down the criteria that cause this issue and it only seems to be a problem if the records are displayed within a subform, AND if the main form containing this subform also has Form Headers/Footers switched on. Unfortunately, I want to use subforms a lot and I want to use headers/footers a lot.
I've attached a tiny sample DB to illustrate the problem. It contains a few test forms:
frmMainWithoutSubform:
This is just a simple form with no subform and no form header/footer.
frmMainWithoutSubform(WithFrmHdrFtr):
As above but with form header/footer.
frmMainWithSubform:
A form containing a subform but no form header/footer.
frmMainWithSubform(WithFrmHdrFtr):
As above but with form header/footer.
To see my problem in action, just open one of the above 4 forms and click in any textbox from a record beyond the first.
Then resize the window as small as you can. (Actually, all you need to do is to make the height small enough so that the header and footer meet, if it has them.)
Then, when you resize the window back to a large enough size to enable you to see the records, you can see if the problem occurs or not.
If the main form has headers/footers AND the records are within a subform (ie the last of the 4 examples described above), then it appears that the FIRST record now has the focus. Otherwise, the focus seems to stay on whichever control it was on before the resize - which is where I would like it always to stay during a form resize.
I've added a load of debug statements to see if that helps explain:
It appears that the entire subform is unloaded when you resize the main form small enough, and then reloaded when you resize it large enough for it again. However, the act of unloading/reloading causes the current record to be reset to the first one.
I need such forms to be resizable so, as an interface designer, I need to cater for any eventuality. If I'm letting the user resize the form, I need to be able to cope with what happens if the user resizes to such an extreme, even if there isn't much likelihood that the user would do that. The point is, they may do.
So, can anyone explain why this happens? Have I made a schoolboy error that can easily be fixed?
Many thanks in advance to anyone who can help.
I'm fairly new to Access programming and, despite being very familiar with the syntax of VB/VBA, the behaviour of the Access data-bound forms can sometimes be quite alien to me.
I can go into the details of my particular coding "challenge" if asked, but I think my problem can be brought down to the following question:
Why does the current record change back to the first record after a particular resize of the form?
To elaborate, if I have a form which has a "Continuous Forms"-style view of its records, then I don't want the currently selected record to change simply because the form has been resized. But it seems to do exactly that - the focus moves back to the first record.
I've tried to pin down the criteria that cause this issue and it only seems to be a problem if the records are displayed within a subform, AND if the main form containing this subform also has Form Headers/Footers switched on. Unfortunately, I want to use subforms a lot and I want to use headers/footers a lot.
I've attached a tiny sample DB to illustrate the problem. It contains a few test forms:
frmMainWithoutSubform:
This is just a simple form with no subform and no form header/footer.
frmMainWithoutSubform(WithFrmHdrFtr):
As above but with form header/footer.
frmMainWithSubform:
A form containing a subform but no form header/footer.
frmMainWithSubform(WithFrmHdrFtr):
As above but with form header/footer.
To see my problem in action, just open one of the above 4 forms and click in any textbox from a record beyond the first.
Then resize the window as small as you can. (Actually, all you need to do is to make the height small enough so that the header and footer meet, if it has them.)
Then, when you resize the window back to a large enough size to enable you to see the records, you can see if the problem occurs or not.
If the main form has headers/footers AND the records are within a subform (ie the last of the 4 examples described above), then it appears that the FIRST record now has the focus. Otherwise, the focus seems to stay on whichever control it was on before the resize - which is where I would like it always to stay during a form resize.
I've added a load of debug statements to see if that helps explain:
frmMainWithSubform(WithFrmHdrFtr).frmTheSubform: orderno_Exit
frmMainWithSubform(WithFrmHdrFtr).frmTheSubform: orderno_LostFocus
frmMainWithSubform(WithFrmHdrFtr).frmTheSubform: Unload
frmMainWithSubform(WithFrmHdrFtr).frmTheSubform: Close
frmMainWithSubform(WithFrmHdrFtr).frmTheSubform: Open
frmMainWithSubform(WithFrmHdrFtr).frmTheSubform: Load
frmMainWithSubform(WithFrmHdrFtr).frmTheSubform: Resize
frmMainWithSubform(WithFrmHdrFtr).frmTheSubform: Current
frmMainWithSubform(WithFrmHdrFtr).frmTheSubform: orderno_Enter
It appears that the entire subform is unloaded when you resize the main form small enough, and then reloaded when you resize it large enough for it again. However, the act of unloading/reloading causes the current record to be reset to the first one.
I need such forms to be resizable so, as an interface designer, I need to cater for any eventuality. If I'm letting the user resize the form, I need to be able to cope with what happens if the user resizes to such an extreme, even if there isn't much likelihood that the user would do that. The point is, they may do.
So, can anyone explain why this happens? Have I made a schoolboy error that can easily be fixed?
Many thanks in advance to anyone who can help.