How to MS Access field grows as per data in a form (1 Viewer)

rehanemis

Registered User.
Local time
Today, 15:41
Joined
Apr 7, 2014
Messages
195
Hi,
I trying to add report to subform/subreport based on user choice and button click. The issue I am facing that the text field doesn't grow according to the data in a field. Please suggest how to set Form field grow (not report) automatically.

thanks
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:41
Joined
Oct 29, 2018
Messages
21,358
You will have to use code for that. Are you using a continuous form?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 11:41
Joined
Feb 19, 2013
Messages
16,554
bit confused about the actual requirement - are you saying you have a subreport on a form and it is the subreport control itself does not grow, or the textbox on the subreport does not grow?

if the latter set the report control can grow/shrink properties.

Stephen Lebans produced an example many years ago for a form view


Very much doubt it will work in a continuous form
 

rehanemis

Registered User.
Local time
Today, 15:41
Joined
Apr 7, 2014
Messages
195
Sorry for not clearing the things. I have about 10 forms so based on the user search I would like to show form data on SubForm/SubReport Control box. I want to make CountryName Field in a Form to grow Automatically based on the contents in the form field.
field grow.JPG
 

rehanemis

Registered User.
Local time
Today, 15:41
Joined
Apr 7, 2014
Messages
195
You will have to use code for that. Are you using a continuous form?
As you see the snap shot I have to make totally dynamically showing the forms based on user search. So I will have more than 6 Text Fields for user to search and as per user input I would like to show relevant form.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:41
Joined
Oct 29, 2018
Messages
21,358
As you see the snap shot I have to make totally dynamically showing the forms based on user search. So I will have more than 6 Text Fields for user to search and as per user input I would like to show relevant form.
The snapshot looks like you're using a Split Form, is that correct? I am asking the type of form you're using, because it makes a difference to what you're asking to do.
 

rehanemis

Registered User.
Local time
Today, 15:41
Joined
Apr 7, 2014
Messages
195
The snapshot looks like you're using a Split Form, is that correct? I am asking the type of form you're using, because it makes a difference to what you're asking to do.
Single Form I am using
2.JPG
 

rehanemis

Registered User.
Local time
Today, 15:41
Joined
Apr 7, 2014
Messages
195
Subform/Subreport using design view.
That may be, but you're also using an Unbound control to display the part that you want to expand. What type of control is that? That's the one that really matter
 

CJ_London

Super Moderator
Staff member
Local time
Today, 11:41
Joined
Feb 19, 2013
Messages
16,554
here is an example - just set the control in the report cangrow property to yes
 

Attachments

  • Database14.accdb
    440 KB · Views: 200

theDBguy

I’m here to help
Staff member
Local time
Today, 04:41
Joined
Oct 29, 2018
Messages
21,358
Subform/Subreport using design view.
Getting closer. What type of object do you display in that Subform/Subreport control? It looks like a Datasheet in your image.
 

rehanemis

Registered User.
Local time
Today, 15:41
Joined
Apr 7, 2014
Messages
195
here is an example - just set the control in the report cangrow property to yes
Its all about the form actually, not to set it for report. Using this code i am setting form dynamically. Me.mySubForm.SourceObject = "qry_TSYSCountryCodesTmp"
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:41
Joined
Oct 29, 2018
Messages
21,358
Its all about the form actually, not to set it for report. Using this code i am setting form dynamically. Me.mySubForm.SourceObject = "qry_TSYSCountryCodesTmp"
Ah, that looks like you're using a Query object. In that case, check out the Height property of the Datasheet object. However, you cannot set individual row heights. Once you increase the height, all rows will have the same height. Is that okay with you?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 11:41
Joined
Feb 19, 2013
Messages
16,554
so if it is a datasheet use vba code to set the columnwidth to -2 - it will then resize the width automatically
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:41
Joined
Oct 29, 2018
Messages
21,358
so if it is a datasheet use vba code to set the columnwidth to -2 - it will then resize the width automatically
@CJ_London I could be mistaken, but I think we're talking about height, not width. Can Grow only applies to height, right?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 11:41
Joined
Feb 19, 2013
Messages
16,554
Can Grow only applies to height, right?
correct but I'm totally confused about what the OP is actually using - a datasheet? a form? a report? a query?

I provided an example using a subreport that looks like a datasheet and can grow - I didn't add it but you can add an event to the report control to open another form whatever.

Looks like this

image_2022-05-25_171648102.png


But the OP's response was

Its all about the form actually, not to set it for report. Using this code i am setting form dynamically. Me.mySubForm.SourceObject = "qry_TSYSCountryCodesTmp"
so sounds like the OP does not have a datasheet form or report but a query.

you can use the code

mysubformcontrol.form.rowheight=567

to adjust a datasheet row height - but it applies to all rows, whereas cangrow only impacts rows where there is a need to grow
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 04:41
Joined
Oct 29, 2018
Messages
21,358
so sounds like the OP does not have a datasheet form or report but a query.
That is correct! That is also my impression. The OP is using a Single Form with a Subform/Subreport Control on it, and they adjust the SourceObject by assigning it a Query object.

I was wondering if all is needed is the Subform RowHeight or does it have to be the ActiveDatasheet RowHeight (or something else)?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 11:41
Joined
Feb 19, 2013
Messages
16,554
Depends where you have the code - I would suggest after the code that assigns a query to the source object.

the code as I suggested works, just need to change the subform control name and set a height to suit.

but suspect the next question will be ‘how do I determine the height required?’.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:41
Joined
May 7, 2009
Messages
19,175
I trying to add report to subform/subreport based on user choice and button click.
what you actually have is a subform, not a subreport.
with Report, that would be easy.
Also doable, but will require code (maybe much).
why not, instead of the row height adjusting, just make it fixed height and
let the Font size adjust-to-fit?
never tried, but will work unless you have a Page-full of text.
 

Users who are viewing this thread

Top Bottom