Center Focus on Field

P

PPCO

I'm wondering if it's possible to center a field with set focus. Right now,
the field on my form appears at the top of the screen--is it possible to
center it (I have a multi-page form).
Thank you
 
A

Arvin Meyer [MVP]

Did you want to move a textbox relative to the form, or the form relative to
the Access window?

The Top and Left properties of a textbox will move it relative to the form.

The MoveSize Method will move the form relative to the Access window, as in:

DoCmd.MoveSize 1440, 2400, , 2000

The syntax is:

DoCmd.MoveSize
[, down][, width][, height]

and all measurements are in Twips (1440 Twips to the inch)​
 
P

PPCO

The MoveSize command looks like what I want. I can't seem to get it to work
though. I'm using the following code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me![Customer] = "Mutual" And IsNull(Me![Returns]) Then
MsgBox "You must enter Returns."
Cancel = True
[Returns].SetFocus
End If

End Sub

when the above code is activated, that's when I want the [Returns] field to
be in the center of the screen. I've tried putting the code in a couple
different places, but can't seem to get it to work.

I've written the following:
DoCmd.MoveSize([0], [700], [0], [0])

Arvin Meyer said:
Did you want to move a textbox relative to the form, or the form relative to
the Access window?

The Top and Left properties of a textbox will move it relative to the form.

The MoveSize Method will move the form relative to the Access window, as in:

DoCmd.MoveSize 1440, 2400, , 2000

The syntax is:

DoCmd.MoveSize
[, down][, width][, height]

and all measurements are in Twips (1440 Twips to the inch)
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

PPCO said:
I'm wondering if it's possible to center a field with set focus. Right
now,
the field on my form appears at the top of the screen--is it possible to
center it (I have a multi-page form).
Thank you


.
 
A

Arvin Meyer [MVP]

You can put the code in your event below, just after the MsgBox statement.
Your code:

DoCmd.MoveSize([0], [700], [0], [0])

moves the form to the top of the Access window, and just under a half inch
to the right of the left side of that window.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


PPCO said:
The MoveSize command looks like what I want. I can't seem to get it to
work
though. I'm using the following code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me![Customer] = "Mutual" And IsNull(Me![Returns]) Then
MsgBox "You must enter Returns."
Cancel = True
[Returns].SetFocus
End If

End Sub

when the above code is activated, that's when I want the [Returns] field
to
be in the center of the screen. I've tried putting the code in a couple
different places, but can't seem to get it to work.

I've written the following:
DoCmd.MoveSize([0], [700], [0], [0])

Arvin Meyer said:
Did you want to move a textbox relative to the form, or the form relative
to
the Access window?

The Top and Left properties of a textbox will move it relative to the
form.

The MoveSize Method will move the form relative to the Access window, as
in:

DoCmd.MoveSize 1440, 2400, , 2000

The syntax is:

DoCmd.MoveSize
[, down][, width][, height]

and all measurements are in Twips (1440 Twips to the inch)
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

PPCO said:
I'm wondering if it's possible to center a field with set focus. Right
now,
the field on my form appears at the top of the screen--is it possible
to
center it (I have a multi-page form).
Thank you


.
 
P

PPCO

It gives me the error: "Compile Error: Expected:="
My code looks like this:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me![Customer] = "Mutual" And IsNull(Me![Returns]) Then
MsgBox "You must enter Returns."
DoCmd.MoveSize ([0], [700], [0], [0])
Cancel = True
[Returns].SetFocus
End If

End Sub

Arvin Meyer said:
You can put the code in your event below, just after the MsgBox statement.
Your code:

DoCmd.MoveSize([0], [700], [0], [0])

moves the form to the top of the Access window, and just under a half inch
to the right of the left side of that window.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


PPCO said:
The MoveSize command looks like what I want. I can't seem to get it to
work
though. I'm using the following code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me![Customer] = "Mutual" And IsNull(Me![Returns]) Then
MsgBox "You must enter Returns."
Cancel = True
[Returns].SetFocus
End If

End Sub

when the above code is activated, that's when I want the [Returns] field
to
be in the center of the screen. I've tried putting the code in a couple
different places, but can't seem to get it to work.

I've written the following:
DoCmd.MoveSize([0], [700], [0], [0])

Arvin Meyer said:
Did you want to move a textbox relative to the form, or the form relative
to
the Access window?

The Top and Left properties of a textbox will move it relative to the
form.

The MoveSize Method will move the form relative to the Access window, as
in:

DoCmd.MoveSize 1440, 2400, , 2000

The syntax is:

DoCmd.MoveSize
[, down][, width][, height]

and all measurements are in Twips (1440 Twips to the inch)
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

I'm wondering if it's possible to center a field with set focus. Right
now,
the field on my form appears at the top of the screen--is it possible
to
center it (I have a multi-page form).
Thank you


.



.
 
D

Douglas J. Steele

Get rid of the parentheses in the MoveSize method:

DoCmd.MoveSize 0, 700, 0, 0

Methods seldom (if ever) use parentheses.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PPCO said:
It gives me the error: "Compile Error: Expected:="
My code looks like this:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me![Customer] = "Mutual" And IsNull(Me![Returns]) Then
MsgBox "You must enter Returns."
DoCmd.MoveSize ([0], [700], [0], [0])
Cancel = True
[Returns].SetFocus
End If

End Sub

Arvin Meyer said:
You can put the code in your event below, just after the MsgBox
statement.
Your code:

DoCmd.MoveSize([0], [700], [0], [0])

moves the form to the top of the Access window, and just under a half
inch
to the right of the left side of that window.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


PPCO said:
The MoveSize command looks like what I want. I can't seem to get it to
work
though. I'm using the following code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me![Customer] = "Mutual" And IsNull(Me![Returns]) Then
MsgBox "You must enter Returns."
Cancel = True
[Returns].SetFocus
End If

End Sub

when the above code is activated, that's when I want the [Returns]
field
to
be in the center of the screen. I've tried putting the code in a couple
different places, but can't seem to get it to work.

I've written the following:
DoCmd.MoveSize([0], [700], [0], [0])

:

Did you want to move a textbox relative to the form, or the form
relative
to
the Access window?

The Top and Left properties of a textbox will move it relative to the
form.

The MoveSize Method will move the form relative to the Access window,
as
in:

DoCmd.MoveSize 1440, 2400, , 2000

The syntax is:

DoCmd.MoveSize
[, down][, width][, height]

and all measurements are in Twips (1440 Twips to the inch)
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

I'm wondering if it's possible to center a field with set focus.
Right
now,
the field on my form appears at the top of the screen--is it
possible
to
center it (I have a multi-page form).
Thank you


.



.
 
A

Arvin Meyer [MVP]

Douglas J. Steele said:
Get rid of the parentheses in the MoveSize method:

DoCmd.MoveSize 0, 700, 0, 0

Methods seldom (if ever) use parentheses.

And the original example I provided didn't have them either. <g>
 
P

PPCO

The brackets and parentheses are from a novice trying to design a database:).
When I typed in the docmd.movesize it popped up the parentheses and backets
so I thought I was supposed to keep those.

David W. Fenton said:
DoCmd.MoveSize([0], [700], [0], [0])

Er, what's with the brackets?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top