Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Move texbox or label in Access report 1

Status
Not open for further replies.

cP6uH

Programmer
May 21, 2003
17
0
0
CA
Is there a way to move any object, like texbox, label, checkbox through code when you run a report ?

I tried .top property and .move, and they both didn't work.

Is there some other way of doing it ??

Thanks.
Dragan
 
Okay, I'm assuming you're using the relevant report section's OnFormat event to try to do this, yes? Must admit I've never tried moving controls, but if Access won't let you modify a control's Top property in this event, have you considered having two controls, one in the 'before' position that's visible and one in the 'after' position that is invisible. Then you can use the report section's OnFormat event to toggle their visibilities, i.e.
Code:
Control1.Visible = Not Control1.Visible
Control2.Visible = Not Control2.Visible
And setting control visibility in the OnFormat event definitely does work!

Hope this helps.

[pc2]
 
You can change the top, left, width property of a control or label through code. But, you must use twips value to move the control. Twips are 1/1440". So, if you want to move a control everyother time from one spot to another for example use this VBA code in the OnFormat of the Detail Section:
If Me.CONTROL_NAME.Top = 240 Then
Me.CONTROL_NAME.Top = 0
Else
Me.CONTROL_NAME.Top = 240
End If

The 240 value of twips is equal to .1667 inches. So, you probably were moving the control but it wasn't visible. If you moved it one inch by assigning 1 to the Top property it would only move 1 twip. very small.

Let me know if this helps you.

Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
I'm so stupid .... After reading your reply I've realized that I've put the code into OnPrint event, and that's why it wouldn't allow me to modify control's Top property.

It works fine now that it's in OnFormat event.

Thanks for your help.

Dragan
 
Well it's me again... I have one more problem now..
I want to modify height of the ReportHeader, and I get the error message that says "This property is read-only and can't be set.".

This is the code i'm using :

Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)

Me.Height = 1500

End Sub


Any suggestions ?

Thank you
Dragan
 
Ok, stupid me again.
Me.ReportHeader.Height works fine....

I was missing "ReportHeader".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top