By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,027 Members | 1,261 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,027 IT Pros & Developers. It's quick & easy.

How To Move a Command Button On A Form?

100+
P: 132
I have a command button on a form. When the command button is clicked, I would like to relocate it on the form. I thought I would do so using the LEFT and TOP properties, but I'm getting no love. The code looks something like this:

Me.[BtnClose].left = 2.1222

the posistion number does not seem to make a difference as the button always appears to the far left....what am I missing??
Aug 7 '07 #1
Share this Question
Share on Google+
6 Replies


Rabbit
Expert Mod 10K+
P: 12,383
You may be seeing inches in your properties but all the controls are measured in twips. The help files will give you the conversion rate for twips to inches, which is what I assume is what you're using. I think it's something like 14 twips to an inch.
Aug 8 '07 #2

missinglinq
Expert 2.5K+
P: 3,532
Not quite, Rabbit! It's 1440 twips/inch! So I suspect that the code is working, it's just difficult for the human eye to percieve the button moving 0.0014737 of an inch!

My question is "Why?"

Linq ;0)>
Aug 8 '07 #3

Rabbit
Expert Mod 10K+
P: 12,383
I was way off...

twip: Unit of measurement that is equal to 1/20 of a point, or 1/1,440 of an inch. There are 567 twips in a centimeter.
Aug 8 '07 #4

ADezii
Expert 5K+
P: 8,669
I have a command button on a form. When the command button is clicked, I would like to relocate it on the form. I thought I would do so using the LEFT and TOP properties, but I'm getting no love. The code looks something like this:

Me.[BtnClose].left = 2.1222

the posistion number does not seem to make a difference as the button always appears to the far left....what am I missing??
'To Move the Command Button 2 inches from the Left of the Form,
'2 inches from the Top of the Form, resize it to 4 inches in Width,
'resize it to 2.5 inches in Height

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdTest_Click()
  2. 'Easier to enter measurements in inches
  3. Const INCHES_TO_TWIPS = 1440
  4.  
  5.   With Me![cmdTest]
  6.     .Left = 2 * INCHES_TO_TWIPS
  7.     .Top = 2 * INCHES_TO_TWIPS
  8.     .Width = 4 * INCHES_TO_TWIPS
  9.     .Height = 2.5 * INCHES_TO_TWIPS
  10.   End With
  11. End Sub
Aug 8 '07 #5

100+
P: 132
'To Move the Command Button 2 inches from the Left of the Form,
'2 inches from the Top of the Form, resize it to 4 inches in Width,
'resize it to 2.5 inches in Height

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdTest_Click()
  2. 'Easier to enter measurements in inches
  3. Const INCHES_TO_TWIPS = 1440
  4.  
  5.   With Me![cmdTest]
  6.     .Left = 2 * INCHES_TO_TWIPS
  7.     .Top = 2 * INCHES_TO_TWIPS
  8.     .Width = 4 * INCHES_TO_TWIPS
  9.     .Height = 2.5 * INCHES_TO_TWIPS
  10.   End With
  11. End Sub
THAT DID THE TRICK!!! THANKS FELLAS!!
Aug 8 '07 #6

missinglinq
Expert 2.5K+
P: 3,532
Glad we could help!

Linq ;0)>
Aug 8 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.