labels or textboxes?

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 03:55
Joined
Sep 12, 2006
Messages
16,030
I want to populate a text box in code, but it isnt letting me do that in the open event.

eg
mytextbox = "some text" (doesn't work)
mylabel.caption = "some text" (does work)

do i need a different event or technique/syntax

I have changed them to labels - but i dont get a "can grow/shrink" property with a label
 
If unbound it should work.

If bound, you should do it in the On Load event so the record source is loaded and therefore the text box can be changed (including the underlying recordset).
 
spurred on by your reply, i had another go,

its the event - you cant do it in the open event - but it works in the section print event

.....

but then - you can assign to text boxes in the header and footer sections, but not in the detail section.

or at least, that's happening to me!
 
Last edited:
oops, sorry I missed that you were dealing with reports. :o
 
gemma,

Let say you want to put the text box in the report header;

Right click on the Properties of the Report Header and put your code behind
"On Format"

From my test db:

Code:
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
Me.txtTest = "Now is the time"
End Sub
 
i realised you could do it in the headers etc - see post 3


but it's crazy - it definitley wasn't working before - and now it is - i can set text boxes in any section.
 
I understand now

if you have an unbound text box, and put somethnig into it as the control source

say ="some text"

THEN you get an error when you try to put something different in it in a format or p[rint event - but if you leave it unbound, then you can set it at run time.

does that make sense?
 
Dave,

To my knowledge you can't set a default value for an unbound text box in its control source it has to be done with code.

.................I could be wrong.


Do you want to use code only or input from your user to fill in the value?
 

Users who are viewing this thread

Back
Top Bottom