labels or textboxes? (1 Viewer)

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 03:50
Joined
Sep 12, 2006
Messages
15,653
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
 

boblarson

Smeghead
Local time
Yesterday, 19:50
Joined
Jan 12, 2001
Messages
32,059
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).
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 03:50
Joined
Sep 12, 2006
Messages
15,653
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:

boblarson

Smeghead
Local time
Yesterday, 19:50
Joined
Jan 12, 2001
Messages
32,059
oops, sorry I missed that you were dealing with reports. :eek:
 

ansentry

Access amateur
Local time
Today, 12:50
Joined
Jun 1, 2003
Messages
995
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
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 03:50
Joined
Sep 12, 2006
Messages
15,653
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.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 03:50
Joined
Sep 12, 2006
Messages
15,653
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?
 

ansentry

Access amateur
Local time
Today, 12:50
Joined
Jun 1, 2003
Messages
995
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

Top Bottom