Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 26th, 2006, 10:38 PM
Authorized User
 
Join Date: Dec 2003
Location: Phnom Penh, KH, Cambodia.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ysiline Send a message via Yahoo to ysiline
Default Error in assigning "TopMargin" property

Can anybody tell me how can I set the value of "TopMargin" property of a control at runtime from VBA module?

I always got error when using:
objControl.Properties("TopMargin")=0.05

Hope that everyone can help soon.

Regards,
========
mKhmer
Reply With Quote
  #2 (permalink)  
Old March 26th, 2006, 10:46 PM
Authorized User
 
Join Date: Dec 2003
Location: Phnom Penh, KH, Cambodia.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ysiline Send a message via Yahoo to ysiline
Default

(^_^)
Reply With Quote
  #3 (permalink)  
Old March 26th, 2006, 11:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

I suspect its 'cause the location of the display info is measured in twips per inch. So declare a constant to convert inches to twips, then use it like:

Code:
Private Sub Form_Load()

    ' used to convert inches to twips
    Const twipsPerInch As Long = 1440

    Dim objControl As Control
    For Each objControl In Me.Controls
        With objControl
            Select Case .ControlType
                Case acLabel
                    .Properties("TopMargin") = 0.25 * twipsPerInch
                Case acTextBox
                    .Properties("TopMargin") = 0.05 * twipsPerInch
            End Select
        End With
    Next objControl
End Sub

0.05 * 1440 would place your display info 72 twips from the top edge of the control.

HTH,

Bob
Reply With Quote
  #4 (permalink)  
Old March 27th, 2006, 12:15 AM
Authorized User
 
Join Date: Dec 2003
Location: Phnom Penh, KH, Cambodia.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ysiline Send a message via Yahoo to ysiline
Default

Well, I got the point of that TwipsPerInch. Thank you.

But, I still get the error of:

You entered an expression that has an invalid reference to the property TopMargin.

witht below code:

ObjControl.Properties("TopMargin") = 0.05 * twipsPerInch

Thank you,

Reply With Quote
  #5 (permalink)  
Old March 27th, 2006, 12:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

What type of control does the objControl variable refer too? Need to see more of your code.

Bob

Reply With Quote
  #6 (permalink)  
Old March 27th, 2006, 12:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Is objControl set correctly to an instance of an object that supports the TopMargin property?

Bob

Reply With Quote
  #7 (permalink)  
Old March 27th, 2006, 12:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

I can reproduce your error (2455) if I try to set the TopMargin property of a control (like a commandbutton) that doesn't support the TopMargin property. The only objects that do are textbox, label, and printer objects.

Bob

Reply With Quote
  #8 (permalink)  
Old March 27th, 2006, 12:44 AM
Authorized User
 
Join Date: Dec 2003
Location: Phnom Penh, KH, Cambodia.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ysiline Send a message via Yahoo to ysiline
Default

I see, it sounds like that error is happened when I tried to work with Command Button, let me try to remove them out of command button.

Thank you....and I will report how it work later.


Reply With Quote
  #9 (permalink)  
Old March 27th, 2006, 12:58 AM
Authorized User
 
Join Date: Dec 2003
Location: Phnom Penh, KH, Cambodia.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ysiline Send a message via Yahoo to ysiline
Default

Ya!!!

You are right....I got it done now.

Big Thank "BOB"

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error - Object doesn't support this property jamara VBScript 1 September 10th, 2006 05:13 AM
Checkbox Property Error twsinc Access VBA 6 February 10th, 2006 05:43 AM
Invalid use of property error. Bob Rupp BOOK: Beginning Access 2003 VBA 1 March 4th, 2005 09:09 AM
Error in Correlation Property Initialization vijay_rb Biztalk 1 August 17th, 2004 08:17 AM
Invalid Use of Property Compile Error dubs70 Access VBA 8 March 9th, 2004 03:19 PM



All times are GMT -4. The time now is 12:31 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.