LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Prevent "standard" key event in userform

"Oskar von dem Hagen" skrev i melding
...
(Bullen et al. write "Most VBA users will never have to create their own

objects because Excel already provides all of the objects they need." That's
why I skipped the chapter on class modules. :-) )

Reading books like that makes you more than "most excel users" ;-)

I was surprised not to find a ready solution in the newsgroup. What do

other authors do, force people to use the mouse?

When you've done this a few times it't pretty quick to set up again. There
will always me more scenarios than ready-to-go solutions.

My hopefully last problem in this thread is probably trivial but I haven't

figured it out yet. Why does the class modul not recognize the subroutine
bnNext_Click, containd in the UserForm in the same Project?

The class module is NOT in the userform, it is simply a collection of
abstract rules of behavior for a userform textbox.

This is purist stuff, but still: You have more than one way to call the
"Next whatever" action. PgUp, buttonclick and maybe morenow or later. Then
do not place the action in the button code, separate it and call it from
wherever. Put this in the userform module:

Public Sub NextRec()
MsgBox "Next"
End Sub

Public Sub PrevRec()
MsgBox "Previous"
End Sub

and make your button code do this:

Private Sub BnNext_Click()
NextRec
End Sub

Private Sub bnPrevious_Click()
PrevRec
End Sub

Now (note the Public in the subs) you can call it also from everywhere as
long as you address it. Edit your class code to

Private Sub txtbox_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
Select Case KeyCode
Case 34
UserForm1.NextRec
Case 33
UserForm1.PrevRec
Case Else
Exit Sub
End Select
KeyCode = 0
End Sub

P.S. I love the "skrev i melding".


That's norwegian. So am I :-)

HTH. Best wishes Harald


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use "standard deviation" option in Y error bar menu? Michael Levin Charts and Charting in Excel 1 April 24th 10 01:35 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
In Excel 2003 is there a way to prevent "Save As" and "Print"? lucky2000 Excel Discussion (Misc queries) 3 April 26th 07 02:49 PM
Standard font in a "New Microsoft Excel Worksheet.xls" wont change Prunetart Excel Discussion (Misc queries) 0 September 15th 06 10:36 AM
Prevent "standard" key event in userform Harald Staff Excel Programming 0 May 28th 04 11:36 PM


All times are GMT +1. The time now is 06:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"