Show empty fields on subform rather than blank subform when no records are associated
up vote
0
down vote
favorite
I am using a subform on my main contact form to display address data. I have a field on the subform that concatenates the values of all the constituent parts of the address- attn line, street and number, city, region, etc. This just makes it easy to view, but edits or additions take place through a popup form with separate fields for each of these parts of the address. I would like the subform to look the same whether or not any addresses have been added for that contact, but when the query to get the addresses for one contact has no results, the subform is totally blank. I'm looking for a way to let a blank field display before an address is added, and keep my labels visible as well.
I tried adding a rectangle of the same size and format as my text box control, then putting that behind the text box, but even with the rectangle, my subform is totally blank when no addresses have been entered. It is a blank box of just the subform background color- no rectangles, no labels, nothing.
The subform is set with the control source as a query that finds the address records for the contact ID that corresponds to the main form.
ms-access ms-access-2016
migrated from dba.stackexchange.com Nov 7 at 8:38
This question came from our site for database professionals who wish to improve their database skills and learn from others in the community.
add a comment |
up vote
0
down vote
favorite
I am using a subform on my main contact form to display address data. I have a field on the subform that concatenates the values of all the constituent parts of the address- attn line, street and number, city, region, etc. This just makes it easy to view, but edits or additions take place through a popup form with separate fields for each of these parts of the address. I would like the subform to look the same whether or not any addresses have been added for that contact, but when the query to get the addresses for one contact has no results, the subform is totally blank. I'm looking for a way to let a blank field display before an address is added, and keep my labels visible as well.
I tried adding a rectangle of the same size and format as my text box control, then putting that behind the text box, but even with the rectangle, my subform is totally blank when no addresses have been entered. It is a blank box of just the subform background color- no rectangles, no labels, nothing.
The subform is set with the control source as a query that finds the address records for the contact ID that corresponds to the main form.
ms-access ms-access-2016
migrated from dba.stackexchange.com Nov 7 at 8:38
This question came from our site for database professionals who wish to improve their database skills and learn from others in the community.
You mention the pop-up for editing the address data, but is the entire subform read-only (e.g. all controls are locked)? I suppose from the description that the subform also does not allow new records. Correct?
– C Perkins
Nov 8 at 3:58
Correct, the subform itself is enabled but the controls within the subform are not, with the exception of the add/edit command buttons. The subform does not allow new records, but if a user adds a new record via the popup, it will appear in the subform when the popup form closes (I requery the subform.)
– Elizabeth Ham
Nov 8 at 13:46
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using a subform on my main contact form to display address data. I have a field on the subform that concatenates the values of all the constituent parts of the address- attn line, street and number, city, region, etc. This just makes it easy to view, but edits or additions take place through a popup form with separate fields for each of these parts of the address. I would like the subform to look the same whether or not any addresses have been added for that contact, but when the query to get the addresses for one contact has no results, the subform is totally blank. I'm looking for a way to let a blank field display before an address is added, and keep my labels visible as well.
I tried adding a rectangle of the same size and format as my text box control, then putting that behind the text box, but even with the rectangle, my subform is totally blank when no addresses have been entered. It is a blank box of just the subform background color- no rectangles, no labels, nothing.
The subform is set with the control source as a query that finds the address records for the contact ID that corresponds to the main form.
ms-access ms-access-2016
I am using a subform on my main contact form to display address data. I have a field on the subform that concatenates the values of all the constituent parts of the address- attn line, street and number, city, region, etc. This just makes it easy to view, but edits or additions take place through a popup form with separate fields for each of these parts of the address. I would like the subform to look the same whether or not any addresses have been added for that contact, but when the query to get the addresses for one contact has no results, the subform is totally blank. I'm looking for a way to let a blank field display before an address is added, and keep my labels visible as well.
I tried adding a rectangle of the same size and format as my text box control, then putting that behind the text box, but even with the rectangle, my subform is totally blank when no addresses have been entered. It is a blank box of just the subform background color- no rectangles, no labels, nothing.
The subform is set with the control source as a query that finds the address records for the contact ID that corresponds to the main form.
ms-access ms-access-2016
ms-access ms-access-2016
asked Nov 6 at 20:41
Elizabeth Ham
1139
1139
migrated from dba.stackexchange.com Nov 7 at 8:38
This question came from our site for database professionals who wish to improve their database skills and learn from others in the community.
migrated from dba.stackexchange.com Nov 7 at 8:38
This question came from our site for database professionals who wish to improve their database skills and learn from others in the community.
You mention the pop-up for editing the address data, but is the entire subform read-only (e.g. all controls are locked)? I suppose from the description that the subform also does not allow new records. Correct?
– C Perkins
Nov 8 at 3:58
Correct, the subform itself is enabled but the controls within the subform are not, with the exception of the add/edit command buttons. The subform does not allow new records, but if a user adds a new record via the popup, it will appear in the subform when the popup form closes (I requery the subform.)
– Elizabeth Ham
Nov 8 at 13:46
add a comment |
You mention the pop-up for editing the address data, but is the entire subform read-only (e.g. all controls are locked)? I suppose from the description that the subform also does not allow new records. Correct?
– C Perkins
Nov 8 at 3:58
Correct, the subform itself is enabled but the controls within the subform are not, with the exception of the add/edit command buttons. The subform does not allow new records, but if a user adds a new record via the popup, it will appear in the subform when the popup form closes (I requery the subform.)
– Elizabeth Ham
Nov 8 at 13:46
You mention the pop-up for editing the address data, but is the entire subform read-only (e.g. all controls are locked)? I suppose from the description that the subform also does not allow new records. Correct?
– C Perkins
Nov 8 at 3:58
You mention the pop-up for editing the address data, but is the entire subform read-only (e.g. all controls are locked)? I suppose from the description that the subform also does not allow new records. Correct?
– C Perkins
Nov 8 at 3:58
Correct, the subform itself is enabled but the controls within the subform are not, with the exception of the add/edit command buttons. The subform does not allow new records, but if a user adds a new record via the popup, it will appear in the subform when the popup form closes (I requery the subform.)
– Elizabeth Ham
Nov 8 at 13:46
Correct, the subform itself is enabled but the controls within the subform are not, with the exception of the add/edit command buttons. The subform does not allow new records, but if a user adds a new record via the popup, it will appear in the subform when the popup form closes (I requery the subform.)
– Elizabeth Ham
Nov 8 at 13:46
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
Probably the easiest solution is to use the form header for the subform:
- Right click on the Form in Design View and select "Form Header/Footer". Both a footer and header section will be displayed.
- Move all form controls to the header. This can be done en masse by selecting all controls and dragging them to the header.
- For both the Detail and Footer sections, set Visible to False. Optionally collapse the sections to take no vertical space.
That's it. The header remains always visible, including the controls. When the recordset is empty, the controls can still obtain focus but don't allow key presses, etc. Buttons and other action controls remain enabled.
As long as the subform only displays one record at a time, the bound controls in the header will behave as expected for each individual row.
Caveat
Because the described behavior (namely, the form detail section is hidden for an empty recordset when AllowAdditions is set to False) is inherent to an Access form, any solution will involve workarounds that likely will change normal, expected behavior of the subform. Resolutions may exist to any such adverse behavior, but will require more extensive handling using form events and additional programming. This solution doesn't cover all such conditions.
For instance, the given solution will not work for a continuous or datasheet subform since the header is NOT repeated for each row. Also, the header will not resize automatically even if the form properties are set to automatically shrink or grow. Proper handling of Resize events may fix this, but it will involve handling not only the subform events, but also the parent form's events to properly resolve that issue.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Probably the easiest solution is to use the form header for the subform:
- Right click on the Form in Design View and select "Form Header/Footer". Both a footer and header section will be displayed.
- Move all form controls to the header. This can be done en masse by selecting all controls and dragging them to the header.
- For both the Detail and Footer sections, set Visible to False. Optionally collapse the sections to take no vertical space.
That's it. The header remains always visible, including the controls. When the recordset is empty, the controls can still obtain focus but don't allow key presses, etc. Buttons and other action controls remain enabled.
As long as the subform only displays one record at a time, the bound controls in the header will behave as expected for each individual row.
Caveat
Because the described behavior (namely, the form detail section is hidden for an empty recordset when AllowAdditions is set to False) is inherent to an Access form, any solution will involve workarounds that likely will change normal, expected behavior of the subform. Resolutions may exist to any such adverse behavior, but will require more extensive handling using form events and additional programming. This solution doesn't cover all such conditions.
For instance, the given solution will not work for a continuous or datasheet subform since the header is NOT repeated for each row. Also, the header will not resize automatically even if the form properties are set to automatically shrink or grow. Proper handling of Resize events may fix this, but it will involve handling not only the subform events, but also the parent form's events to properly resolve that issue.
add a comment |
up vote
1
down vote
Probably the easiest solution is to use the form header for the subform:
- Right click on the Form in Design View and select "Form Header/Footer". Both a footer and header section will be displayed.
- Move all form controls to the header. This can be done en masse by selecting all controls and dragging them to the header.
- For both the Detail and Footer sections, set Visible to False. Optionally collapse the sections to take no vertical space.
That's it. The header remains always visible, including the controls. When the recordset is empty, the controls can still obtain focus but don't allow key presses, etc. Buttons and other action controls remain enabled.
As long as the subform only displays one record at a time, the bound controls in the header will behave as expected for each individual row.
Caveat
Because the described behavior (namely, the form detail section is hidden for an empty recordset when AllowAdditions is set to False) is inherent to an Access form, any solution will involve workarounds that likely will change normal, expected behavior of the subform. Resolutions may exist to any such adverse behavior, but will require more extensive handling using form events and additional programming. This solution doesn't cover all such conditions.
For instance, the given solution will not work for a continuous or datasheet subform since the header is NOT repeated for each row. Also, the header will not resize automatically even if the form properties are set to automatically shrink or grow. Proper handling of Resize events may fix this, but it will involve handling not only the subform events, but also the parent form's events to properly resolve that issue.
add a comment |
up vote
1
down vote
up vote
1
down vote
Probably the easiest solution is to use the form header for the subform:
- Right click on the Form in Design View and select "Form Header/Footer". Both a footer and header section will be displayed.
- Move all form controls to the header. This can be done en masse by selecting all controls and dragging them to the header.
- For both the Detail and Footer sections, set Visible to False. Optionally collapse the sections to take no vertical space.
That's it. The header remains always visible, including the controls. When the recordset is empty, the controls can still obtain focus but don't allow key presses, etc. Buttons and other action controls remain enabled.
As long as the subform only displays one record at a time, the bound controls in the header will behave as expected for each individual row.
Caveat
Because the described behavior (namely, the form detail section is hidden for an empty recordset when AllowAdditions is set to False) is inherent to an Access form, any solution will involve workarounds that likely will change normal, expected behavior of the subform. Resolutions may exist to any such adverse behavior, but will require more extensive handling using form events and additional programming. This solution doesn't cover all such conditions.
For instance, the given solution will not work for a continuous or datasheet subform since the header is NOT repeated for each row. Also, the header will not resize automatically even if the form properties are set to automatically shrink or grow. Proper handling of Resize events may fix this, but it will involve handling not only the subform events, but also the parent form's events to properly resolve that issue.
Probably the easiest solution is to use the form header for the subform:
- Right click on the Form in Design View and select "Form Header/Footer". Both a footer and header section will be displayed.
- Move all form controls to the header. This can be done en masse by selecting all controls and dragging them to the header.
- For both the Detail and Footer sections, set Visible to False. Optionally collapse the sections to take no vertical space.
That's it. The header remains always visible, including the controls. When the recordset is empty, the controls can still obtain focus but don't allow key presses, etc. Buttons and other action controls remain enabled.
As long as the subform only displays one record at a time, the bound controls in the header will behave as expected for each individual row.
Caveat
Because the described behavior (namely, the form detail section is hidden for an empty recordset when AllowAdditions is set to False) is inherent to an Access form, any solution will involve workarounds that likely will change normal, expected behavior of the subform. Resolutions may exist to any such adverse behavior, but will require more extensive handling using form events and additional programming. This solution doesn't cover all such conditions.
For instance, the given solution will not work for a continuous or datasheet subform since the header is NOT repeated for each row. Also, the header will not resize automatically even if the form properties are set to automatically shrink or grow. Proper handling of Resize events may fix this, but it will involve handling not only the subform events, but also the parent form's events to properly resolve that issue.
edited Nov 8 at 19:34
answered Nov 8 at 16:34
C Perkins
1,73511321
1,73511321
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53185911%2fshow-empty-fields-on-subform-rather-than-blank-subform-when-no-records-are-assoc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You mention the pop-up for editing the address data, but is the entire subform read-only (e.g. all controls are locked)? I suppose from the description that the subform also does not allow new records. Correct?
– C Perkins
Nov 8 at 3:58
Correct, the subform itself is enabled but the controls within the subform are not, with the exception of the add/edit command buttons. The subform does not allow new records, but if a user adds a new record via the popup, it will appear in the subform when the popup form closes (I requery the subform.)
– Elizabeth Ham
Nov 8 at 13:46