PDA

View Full Version : form - cursor position - Excel 2007



otto
11-25-2007, 09:45 AM
1. I have created a data entry form with 8 fields. When the form comes up the cursor points to the second field, rather than the first one. I must have done something wrong when I created the form using the tool box, but I cannot see what the cause is and how to make it point to the first field.

2. The form does not come up when the spreadsheet is displayed. I have to get it via view, macros, view macros, edit, forms, view, object ... which is so convoluted it defeats the purpose of the form.

anybody have a clue what I need to do?

thank you.

(I have to leave now, will be back later this afternoon)

xld
11-25-2007, 09:54 AM
There is a property called TabIndex associated with each control. Set the first cell to visit to TabIndex 1, second to 2, and so on.

tpoynton
11-25-2007, 01:02 PM
I find using Tab Order (under View in VBE) very helpful!

Regarding #2, do you want the form to always be visible when the workbook is opened?

xld
11-25-2007, 01:06 PM
I find using Tab Order (under View in VBE) very helpful!

I find it simpler to select the controls in my required tab order, and then set the TabIndex property to 1. VBA increments each of the successive controls automatically.

otto
11-25-2007, 02:31 PM
Thank you xld.

I found the TabIndex, it is set to one for the first field, but the cursor is not at the first field. I think I cannot set it in the subroutine for the first field, at that time it is too late.

Thank you tpoynton.

I would like the form to come up when I open the Excel file or have an easy key sequence to bring the form to the foreground.

The Tab Order under View is greyed out, I cannot use it.

I think I have to buy a book before I ask any more questions. I have too many problems with really basic stuff. Like all the properties of a field showed on the lower left side of the VBE window, now they are not there any more and I don't know how to get them back. I try things and then I forget what I did and cannot repeat it!

I got a macro to work. It copies data from one sheet to another, reformats and summarizes. I got most of the code from the macro recorder. I thought data entry would be easier by using a form because I can edit the data and create error messages while the data is entered. I got it to work, too. When I enter data into a field it shows up on the form and in the Sheet destination field as it is typed one character at a time. Now it is just minor detail like the cursor that does not want to do what I think it should do.

Thank you for your help.

xld
11-25-2007, 03:43 PM
Thank you xld.

I found the TabIndex, it is set to one for the first field, but the cursor is not at the first field. I think I cannot set it in the subroutine for the first field, at that time it is too late.

Sorry I should have said set it to 0, the TabIndex starts at 0.

xld
11-25-2007, 03:44 PM
Like all the properties of a field showed on the lower left side of the VBE window, now they are not there any more and I don't know how to get them back.

F4 in the VBIDE.

otto
11-25-2007, 05:28 PM
TabIndex = 0 solved my erratic cursor. the F4 brought back the properties of the fields I was looking at. thanks.

tpoynton
11-25-2007, 06:30 PM
I think that putting 'youruserformname.show' in the workbook open event of ThisWorkbook will open the userform when you open the excel file. It will probably be best to have a button or key sequence to open it, because if the userform is closed, the file will need to be closed and opened to reopen the userform.

Lucas has a tutorial here (http://slucas.virtualave.net/Wink/ThisWorkbookModule.htm) explaining how to find ThisWorkbook.

You know, assigning a key sequence to a macro should be relatively straightforward, but I do not know how to do it at present! It might be done through the macro menu.

Regarding a book, I find most things I need via Google, VBA help, an older Excel 2000 book, searching the forum here, and posting questions here - in that order!

otto
11-25-2007, 07:31 PM
thank you tpoynton.

I have no problem running a macro, a form seems to be slightly different, but I will manage.

let's consider this question answered.