Change Subform Columnwidth auto when change data

ootkhopdi

Registered User.
Local time
Today, 18:13
Joined
Oct 17, 2013
Messages
181
Hi All

i have a form named Form1 and subform named SBFRM

subform show data for select query based on value of text box on form 1

subform shows data in datasheet view

my problem is .
data having diffrent lenght of character as In EmpName Field,

Raj
Rajkumar
Rajkumar Sharma

but when it shows in datasheet view, i want to set column width of field , EmpName, is according to data,

i have tried..
me.controlname.columnwidth=-2
but it shows no result

please give me solution

and if u can give me other solution for.. automatically change subform width and height of subform, based on no of record and columnwidth,,,

i also gives more thanks to u..

please give me solutions..

thanks in advance
 
reset its the column width first, then do the auto-adjust of column:

' reset to 1 inch
me.controlname.columnwidth = 1440
' adjust to auto
me.controlname.columnwidth = -2
 
Thanks arnelgp..

But this not working..i dont know why
 
you do the adjustment on your subform's load event, and on the control's after update event:

private sub form_load()
' reset to 1 inch
me.controlname.columnwidth = 1440
' adjust to auto
me.controlname.columnwidth = -2
end if

private controlname_afterupdate()
call form_load()
end sub
 
thanks arnelgp

but it doesn't works when data change in sub form
why not

and in your code
there is an "end if"
how can i use if condition

i can't understand

pls help me
 
sorry remove the "end if".
the code should go the the subform.
 

Users who are viewing this thread

Back
Top Bottom