473,549 Members | 2,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

EXCEL -vb - Spin Button - Focus

5 New Member
Excel 2000 (9.0.2720) vb-6.
We have a column of Cells and the SpinButton. Let say for this example:
column 1 row 1 cell have value "A"
column 1 row 2 cell have value "B"
column 1 row 3 cell have value "C"
Cell with value "A" is is highlited (has focus)
Now we press "SpinButton " down. We exchange values "A" and "B"
so we have B - row 1
A - row 2
C - no change
We want A in row 2 be in focus, so we activate Cells(1,2)in last statement of spin down subroutine.
Well - the cell is activated for a split of second and then SpinButton get a focus - taking focus off our cell !!!. Now
SpinButton is like two CommandButton but CommandButton have a property: TakeFocusOnClic k - TRUE or FALSE but SpinButton don't.(In my opinion MS missed this - hmmmmm?)
So, SpinButton is geting focus after "spin down" event is already finished. Now Cell in row 2 (value A)is active but SpinButton has a focus. If we press "down" again it works good bcse SpinButton (having focus now) is not trying to get focus again. How to solve this ???.
Sep 23 '11 #1
7 5117
Mihail
759 Contributor
What you wish to solve?
Sep 24 '11 #2
Janusz Dacxzko
5 New Member
Well, Mihail
I'm loosing a focus from a cell that should have it - every second time when I press SpinButton. Would be solution - set Focus on SpinButton before pressing it, as I explained before when SpinButton has a focus it don't try get it back, so my cell properly maintain her focus for now, but next clic and SB takes focus again - Kapish ?
Sep 26 '11 #3
Janusz Dacxzko
5 New Member
Sorry, I'm wrong - It is not a solution to set focus on SB, you have to press it first then program knows that it was pressed, besides there is no instruction to set focus or activate SB ??!!
Sep 26 '11 #4
Mihail
759 Contributor
A solution can be:

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Private Sub SpinButton1_GotFocus()
  4.     ActiveCell.Activate
  5. End Sub
  6.  
  7. Private Sub SpinButton1_SpinDown()
  8. Dim R As Integer
  9.     R = ActiveCell.Row + 1
  10.     If R > 65535 Then R = R - 1 'last row in sheet
  11.     Cells(R, 1).Activate
  12. End Sub
  13.  
  14. Private Sub SpinButton1_SpinUp()
  15. Dim R As Integer
  16.     R = ActiveCell.Row - 1
  17.     If R < 1 Then R = R + 1 'Firs row in sheet
  18.     Cells(R, 1).Activate
  19. End Sub
Si, kapish :))
Sep 26 '11 #5
NeoPa
32,564 Recognized Expert Moderator MVP
I handle this irritation by selecting the worksheet that the cell is on. I've sometimes found that not to work though. Try selecting the current selection instead :
Expand|Select|Wrap|Line Numbers
  1. Call Selection.Select
Sep 26 '11 #6
Janusz Dacxzko
5 New Member
Micha,
I totaly overlooked "Object_GotFocu s()". Of course your solution is perfect. Si,Si Kapish now.!
Many thanks
Janusz
Sep 27 '11 #7
Janusz Dacxzko
5 New Member
NeoPa - Thanks - I used Mihail solution.
Cheers
Sep 27 '11 #8

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

Similar topics

2
651
by: Ronny Sigo | last post by:
Hello all, I have to open a readonly Excel sheet from clicking on a button on an access form. So far no problem: Dim ObjXL As Excel.Application Dim ObjXLBook As Excel.Workbook Dim ObjXLSheet As Excel.Worksheet Set ObjXL = CreateObject("Excel.Application") Set ObjXLBook = ObjXL.Workbooks.Open("Mypath\Myfile.xls", , True) Set ObjXLSheet =...
5
8020
by: Mike | last post by:
Can I trigger a button press event without putting focus on the button? I am making a form full of buttons that can be used as a keyboard on a touchscreen. If I have a textbox which has focus and I click the 'Q' button on the form which represents the 'Q' key on the keyboard, nothing gets printed into the textbox because the textbox loses...
0
1191
by: JoRo | last post by:
I am working on a project where I want a very user-friendly interface. I have a datagrid of categories that uses the EditCommandColumn to do in-line editing of the category name. On the page is also a textbox field with an "Add" button to create new categories (This is outside of the datagrid). When the page first loads I use ...
3
4210
by: Philip Townsend | last post by:
I have an aspx page that contains 2 user controls, each containing a seperate textbox and button. I would like to specify that one of the buttons recieve focus when the page loads. Also, I would like that same button to fire its event when the user presses enter. Can anybody help with this? *** Sent via Developersdex...
0
1157
by: devour | last post by:
i am using glade+pygtk+python ,what i wanna do is get a float type number from user, make some mathematical operations using python then output the result using glade. i tried text entry but i found it only accepts strings so i used spin button and it worked but the problem is it takes &displays only integers though i used get value () & set...
3
1589
pentahari
by: pentahari | last post by:
In VB6, I have created the form look like the message box. but one problem has occurred that the one button had already focused but the rectangle focus symbol appeared on the focused button. But the msgbox don't have the rectangle focus symbol on the focused button. For ex: MsgBox "Are you sure?", vbYesNo The above msgbox automatically...
3
7649
by: JFKJr | last post by:
Hello everyone, the following is the code which opens an excel file and creates a toolbar button. And, when I click the toolbar button as shown at line #28, the code should call the "Example" macro. But, it is displaying "The Macro "Example" cannot be found" Message Box. Can anyone suggest an idea on how to call the macro whenever a user...
1
6185
MitchR
by: MitchR | last post by:
Good Morning Folks; I have a question that is pretty far fetched but here goes nothing... I am looking to find a way to insert a macro into an Excel command button located in an Access VBA generated Excel spreadsheet from an Access Module. I can create the spreadsheet, button, and I have the macro to insert into command button. But I am not...
0
7715
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7956
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7808
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5087
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.