ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   User Form focus (https://www.excelbanter.com/excel-programming/313073-user-form-focus.html)

Glen Mettler[_2_]

User Form focus
 
I have a user form that contains options that will be place in the selected
cell. It works fine in modal status. However, I wanted to make the form
non-modal so the user could select more than one cell to insert the data so
they would not have to repeat the action several times.

Here is the problem. When I set the form non-modal, the focus remains in
the cell awaiting input. I cannot select the form. However, I can move the
cursor to another cell and then back and then select the form. I tried to
set the focus to the form or an object in the form (like the OK button).

Have I missed something? I want to run the form non-modal and have the
focus on the form when it is envoked. Is that possible?

Glen



keepITcool

User Form focus
 

Just a guess..

is the form called from a button on a sheet?
(from the controls Toolbox)..

check the button's properties..
ensure that "TakeFocusOnClick" is disabled.

or.. in the macro that calls the form,
activecell.activate
userform1.show vbModeless






keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Glen Mettler" wrote:

I have a user form that contains options that will be place in the
selected cell. It works fine in modal status. However, I wanted to
make the form non-modal so the user could select more than one cell to
insert the data so they would not have to repeat the action several
times.

Here is the problem. When I set the form non-modal, the focus remains
in the cell awaiting input. I cannot select the form. However, I can
move the cursor to another cell and then back and then select the
form. I tried to set the focus to the form or an object in the form
(like the OK button).

Have I missed something? I want to run the form non-modal and have
the focus on the form when it is envoked. Is that possible?

Glen




Glen Mettler[_2_]

User Form focus
 
The form is called from a doubleclick in the cell. I have code in the
SheetBeforeDoubleClick event for the workbook. The code captures the
column. Then a series of If statements call the form if the column matches:
for example:
If sCol = Range("Dist_Modl").Value Then
pRow = Selection.Row
EACTcol = Range("EACT").Value
hrscol = Range("Dist_Modl").Value
If Cells(pRow, EACTcol).Value = "T" Or Cells(pRow, EACTcol).Value =
"L" Then
HoursDistribution.Show
End If
'Cells(ActiveCell.Row + 1, sCol).Select
End If

note that the last code statement of the major If statement
(Cells(ActiveCell.row...) is commented. If I uncomment this statment, the
form works as I want it to but it cell is now on the next row. I want the
focus to remain on the cell selected. If I comment the code, the focus
remains in the cell waiting for user input and does not go to the form.

I tried KeepITcool's code and it didn't change anything.

There should be a way to do this.

Glen

"Glen Mettler" wrote in message
...
I have a user form that contains options that will be place in the selected
cell. It works fine in modal status. However, I wanted to make the form
non-modal so the user could select more than one cell to insert the data so
they would not have to repeat the action several times.

Here is the problem. When I set the form non-modal, the focus remains in
the cell awaiting input. I cannot select the form. However, I can move
the cursor to another cell and then back and then select the form. I
tried to set the focus to the form or an object in the form (like the OK
button).

Have I missed something? I want to run the form non-modal and have the
focus on the form when it is envoked. Is that possible?

Glen




Tom Ogilvy

User Form focus
 
replace the commented line with

Cancel = True

--
Regards,
Tom Ogilvy

"Glen Mettler" wrote in message
...
The form is called from a doubleclick in the cell. I have code in the
SheetBeforeDoubleClick event for the workbook. The code captures the
column. Then a series of If statements call the form if the column

matches:
for example:
If sCol = Range("Dist_Modl").Value Then
pRow = Selection.Row
EACTcol = Range("EACT").Value
hrscol = Range("Dist_Modl").Value
If Cells(pRow, EACTcol).Value = "T" Or Cells(pRow, EACTcol).Value

=
"L" Then
HoursDistribution.Show
End If
'Cells(ActiveCell.Row + 1, sCol).Select
End If

note that the last code statement of the major If statement
(Cells(ActiveCell.row...) is commented. If I uncomment this statment, the
form works as I want it to but it cell is now on the next row. I want the
focus to remain on the cell selected. If I comment the code, the focus
remains in the cell waiting for user input and does not go to the form.

I tried KeepITcool's code and it didn't change anything.

There should be a way to do this.

Glen

"Glen Mettler" wrote in message
...
I have a user form that contains options that will be place in the

selected
cell. It works fine in modal status. However, I wanted to make the form
non-modal so the user could select more than one cell to insert the data

so
they would not have to repeat the action several times.

Here is the problem. When I set the form non-modal, the focus remains

in
the cell awaiting input. I cannot select the form. However, I can move
the cursor to another cell and then back and then select the form. I
tried to set the focus to the form or an object in the form (like the OK
button).

Have I missed something? I want to run the form non-modal and have the
focus on the form when it is envoked. Is that possible?

Glen







All times are GMT +1. The time now is 12:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com