I have a form that I do *not* want the user to be able to use the
PageUp/PageDown keys *unless* the cursor is in a particular text box.
I'm using this code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 33, 34
KeyCode = 0
End Select
Exit Sub
But how do I allow use of the PageUp/PageDown keys within a particular text
box? The text box in question - txtNoteText - will contain a lot of text,
perhpas a few pages, that is populated from a memo field.
Thanks in advance.
I would also like to be able to use the mouse wheel to scroll in the text
box, but I am not sure if this is possible. I am using Stephen Lebans
MouseHook DLL, which turns off the mouse wheel in the form, but I cannot get
it to turn back on when the cursor is in the text box
I tried the below code, but it does not work. I would settle for use of the
PageUp / PageDown Key, however...
Private Sub txtNoteText_Enter()
Dim blRet As Boolean
blRet = MouseWheelON
End Sub
Private Sub txtNoteText_Exit(Cancel As Integer)
Dim blRet As Boolean
blRet = MouseWheelOFF(False)
End Sub 12 3925
To see what the currently active control is, try:
Screen.ActiveControl
Be sure to use error handling. Lots can go wrong trying to read that.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"deko" <no****@hotmail.com> wrote in message
news:Tv*******************@newssvr25.news.prodigy. com... I have a form that I do *not* want the user to be able to use the PageUp/PageDown keys *unless* the cursor is in a particular text box.
I'm using this code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Select Case KeyCode Case 33, 34 KeyCode = 0 End Select Exit Sub
But how do I allow use of the PageUp/PageDown keys within a particular
text box? The text box in question - txtNoteText - will contain a lot of text, perhpas a few pages, that is populated from a memo field.
Thanks in advance.
I would also like to be able to use the mouse wheel to scroll in the text box, but I am not sure if this is possible. I am using Stephen Lebans MouseHook DLL, which turns off the mouse wheel in the form, but I cannot
get it to turn back on when the cursor is in the text box
I tried the below code, but it does not work. I would settle for use of
the PageUp / PageDown Key, however...
Private Sub txtNoteText_Enter() Dim blRet As Boolean blRet = MouseWheelON End Sub
Private Sub txtNoteText_Exit(Cancel As Integer) Dim blRet As Boolean blRet = MouseWheelOFF(False) End Sub
> To see what the currently active control is, try: Screen.ActiveControl
Thanks - that seems to work. But the problem now is that after the current
record is scrolled to the bottom of the field, the form jumps to the next
record, which is the behavior I'm trying to avoid. Here is the code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo HandleErr
Select Case KeyCode
Case 33, 34
If Screen.ActiveControl <> Me.txtNoteText Then KeyCode = 0
End Select
[code omitted]
End Sub
Is there a way to prevent the form from moving to the next record?
By the way, the RecordSource for this form is built form a cloned recordset:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo HandleErr
Dim strNid As String
Dim lngNid As Long
Dim rst As DAO.Recordset
Dim blRet As Boolean
blRet = MouseWheelOFF(False)
If Me.OpenArgs = "OldNote" Then
lngNid = Forms!frm0!frm0Notes.Form!Note_ID
strNid = "Note_ID = " & lngNid
Me.RecordSource = "qryNotesEntity"
Set rst = Me.RecordsetClone
rst.FindFirst strNid
Me.Bookmark = rst.Bookmark
Me.NavigationButtons = True
ElseIf Me.OpenArgs = "NewNote" Then
Me.NavigationButtons = False
End If
Me!txtNoteText.SetFocus
Exit_Here:
Exit Sub
HandleErr:
Select Case Err.Number
Case Else
modHandler.LogErr ("frmNotesDetail"), ("Form_Open")
End Select
Resume Exit_Here
End Sub
Try setting the form's Cycle property to Current Record.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"deko" <no****@hotmail.com> wrote in message
news:14*******************@newssvr25.news.prodigy. com... To see what the currently active control is, try: Screen.ActiveControl Thanks - that seems to work. But the problem now is that after the
current record is scrolled to the bottom of the field, the form jumps to the next record, which is the behavior I'm trying to avoid. Here is the code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) On Error GoTo HandleErr Select Case KeyCode Case 33, 34 If Screen.ActiveControl <> Me.txtNoteText Then KeyCode = 0 End Select [code omitted] End Sub
Is there a way to prevent the form from moving to the next record?
By the way, the RecordSource for this form is built form a cloned
recordset: Private Sub Form_Open(Cancel As Integer) On Error GoTo HandleErr Dim strNid As String Dim lngNid As Long Dim rst As DAO.Recordset Dim blRet As Boolean blRet = MouseWheelOFF(False) If Me.OpenArgs = "OldNote" Then lngNid = Forms!frm0!frm0Notes.Form!Note_ID strNid = "Note_ID = " & lngNid Me.RecordSource = "qryNotesEntity" Set rst = Me.RecordsetClone rst.FindFirst strNid Me.Bookmark = rst.Bookmark Me.NavigationButtons = True ElseIf Me.OpenArgs = "NewNote" Then Me.NavigationButtons = False End If Me!txtNoteText.SetFocus Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case Else modHandler.LogErr ("frmNotesDetail"), ("Form_Open") End Select Resume Exit_Here End Sub
The default behaviour for the MouseWHeelOff method is to allow the use
of the MouseWheel within a TextBox control that contains ScrollBars. You
do not need to Start/Stop the MouseHook each time you enter a TexBox
control.
--
HTH
Stephen Lebans http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:40**********************@freenews.iinet.net.a u... To see what the currently active control is, try: Screen.ActiveControl
Be sure to use error handling. Lots can go wrong trying to read that.
-- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org.
"deko" <no****@hotmail.com> wrote in message news:Tv*******************@newssvr25.news.prodigy. com... I have a form that I do *not* want the user to be able to use the PageUp/PageDown keys *unless* the cursor is in a particular text
box. I'm using this code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Select Case KeyCode Case 33, 34 KeyCode = 0 End Select Exit Sub
But how do I allow use of the PageUp/PageDown keys within a
particular text box? The text box in question - txtNoteText - will contain a lot of
text, perhpas a few pages, that is populated from a memo field.
Thanks in advance.
I would also like to be able to use the mouse wheel to scroll in the
text box, but I am not sure if this is possible. I am using Stephen
Lebans MouseHook DLL, which turns off the mouse wheel in the form, but I
cannot get it to turn back on when the cursor is in the text box
I tried the below code, but it does not work. I would settle for
use of the PageUp / PageDown Key, however...
Private Sub txtNoteText_Enter() Dim blRet As Boolean blRet = MouseWheelON End Sub
Private Sub txtNoteText_Exit(Cancel As Integer) Dim blRet As Boolean blRet = MouseWheelOFF(False) End Sub
> Try setting the form's Cycle property to Current Record.
It is currently set that way. I also tried Current Page, but that did not
help. Is this problem due to a limitation with the control itself? Is
there some other control (other than a text box) that may be better for
multiple pages of text? A control that will accomodate Rich Text would be
nice, but scrolling with the Mouse Wheel, or at least the PageUp/PageDown
keys, is all that is really necessary. One caveat - I need to keep the
control unbound. There is a reason I need to use a cloned recordset to
build the RecordSource for the form.
> The default behaviour for the MouseWHeelOff method is to allow the use of the MouseWheel within a TextBox control that contains ScrollBars. You do not need to Start/Stop the MouseHook each time you enter a TexBox control.
Hi and thanks for the reply. Yes, I remember reading about this on your
site. Unfortunately, it's not working that way in this case. The reason
for this, I think, is because either the control is unbound, or because I am
using a cloned recordset. At least those are the only tow differences from
other forms. Here is the Form_Open code, which builds the cloned recordset
from a query, which is the form's RecordSource.
Private Sub Form_Open(Cancel As Integer)
On Error GoTo HandleErr
Dim strNid As String
Dim lngNid As Long
Dim rst As DAO.Recordset
Dim blRet As Boolean
blRet = MouseWheelOFF(False)
If Me.OpenArgs = "OldNote" Then
lngNid = Forms!frm0!frm0Notes.Form!Note_ID
strNid = "Note_ID = " & lngNid
Me.RecordSource = "qryNotesEntity"
Set rst = Me.RecordsetClone
rst.FindFirst strNid
Me.Bookmark = rst.Bookmark
Me.NavigationButtons = True
ElseIf Me.OpenArgs = "NewNote" Then
Me.NavigationButtons = False
End If
Me!txtNoteText.SetFocus
Exit_Here:
Exit Sub
HandleErr:
Select Case Err.Number
Case Else
modHandler.LogErr ("frmNotesDetail"), ("Form_Open")
End Select
Resume Exit_Here
End Sub
It makes absolutely no difference is the TextBox control is unbound or
that you have cloned the recordsource.
1) Place the call to MouseWHeelOff in the Form's Load event as shown in
the sample code.
2) Verify that the return value from the call to MouseWHeelOff is =
TRUE.
Let me know.
--
HTH
Stephen Lebans http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"deko" <no****@hotmail.com> wrote in message
news:IV*****************@newssvr27.news.prodigy.co m... The default behaviour for the MouseWHeelOff method is to allow the
use of the MouseWheel within a TextBox control that contains ScrollBars.
You do not need to Start/Stop the MouseHook each time you enter a TexBox control. Hi and thanks for the reply. Yes, I remember reading about this on
your site. Unfortunately, it's not working that way in this case. The
reason for this, I think, is because either the control is unbound, or
because I am using a cloned recordset. At least those are the only tow differences
from other forms. Here is the Form_Open code, which builds the cloned
recordset from a query, which is the form's RecordSource.
Private Sub Form_Open(Cancel As Integer) On Error GoTo HandleErr Dim strNid As String Dim lngNid As Long Dim rst As DAO.Recordset Dim blRet As Boolean blRet = MouseWheelOFF(False) If Me.OpenArgs = "OldNote" Then lngNid = Forms!frm0!frm0Notes.Form!Note_ID strNid = "Note_ID = " & lngNid Me.RecordSource = "qryNotesEntity" Set rst = Me.RecordsetClone rst.FindFirst strNid Me.Bookmark = rst.Bookmark Me.NavigationButtons = True ElseIf Me.OpenArgs = "NewNote" Then Me.NavigationButtons = False End If Me!txtNoteText.SetFocus Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case Else modHandler.LogErr ("frmNotesDetail"), ("Form_Open") End Select Resume Exit_Here End Sub
> It makes absolutely no difference is the TextBox control is unbound or that you have cloned the recordsource.
1) Place the call to MouseWHeelOff in the Form's Load event as shown in the sample code.
2) Verify that the return value from the call to MouseWHeelOff is = TRUE.
Okay, I put the call to MouseWheelOff in the Form's Load event and tried
this:
Private Sub Form_Load()
Dim blRet As Boolean
blRet = MouseWheelOFF(False)
Debug.Print MouseWheelOFF
End Sub
The result I get in the immediate wiwdow is "False", but the mouse wheel
behaves properly - that is, it is disabled or enabled according to the code.
The scrolling problem with the PageUp/PageDown keys is that the form moves
to the next record (not desired) - even if the form's Cycle property is set
to Current Record. But the text (in the text box of the current record)
will scroll to the bottom (desired). The jump to the next record happens
when the text box reaches the end of the text.
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 33, 34
If Screen.ActiveControl <> Me.txtNoteText Then KeyCode = 0
End Select
End Sub
If I enable the mouse wheel, the text within the text box does *not* scroll,
but the form moves to the next record when attempting to scroll - which is
the behavior I am trying to avoid (while allowing scrolling of the text in
the text box).
I may just try to re-create the entire form... I'm lost here...
Your Debug.Print statement is ending up calling the MouseWheelOff
function again. Debug.Print the returned Boolean variable instead.
I emailed you back that the MDB you sent me will not function as it. It
is imissing a Query and a custom function for error handling etc. Send
me a working MDB and I will debug this for you as the MouseWheelHook
will give you the desired functionality.
:-)
BTW, what version of Access are you using?
--
HTH
Stephen Lebans http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"deko" <no****@hotmail.com> wrote in message
news:15*****************@newssvr27.news.prodigy.co m... It makes absolutely no difference is the TextBox control is unbound
or that you have cloned the recordsource.
1) Place the call to MouseWHeelOff in the Form's Load event as shown
in the sample code.
2) Verify that the return value from the call to MouseWHeelOff is = TRUE. Okay, I put the call to MouseWheelOff in the Form's Load event and
tried this:
Private Sub Form_Load() Dim blRet As Boolean blRet = MouseWheelOFF(False) Debug.Print MouseWheelOFF End Sub
The result I get in the immediate wiwdow is "False", but the mouse
wheel behaves properly - that is, it is disabled or enabled according to the
code. The scrolling problem with the PageUp/PageDown keys is that the form
moves to the next record (not desired) - even if the form's Cycle property
is set to Current Record. But the text (in the text box of the current
record) will scroll to the bottom (desired). The jump to the next record
happens when the text box reaches the end of the text.
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Select Case KeyCode Case 33, 34 If Screen.ActiveControl <> Me.txtNoteText Then KeyCode = 0 End Select End Sub
If I enable the mouse wheel, the text within the text box does *not*
scroll, but the form moves to the next record when attempting to scroll -
which is the behavior I am trying to avoid (while allowing scrolling of the
text in the text box).
I may just try to re-create the entire form... I'm lost here...
> BTW, what version of Access are you using?
Access 2003
updated mdb on the way...
When you mentioned the Vertical ScrollBar was not visible this was
obviously the problem. With no Vertical ScrollBar there are no
MouseWHeel messages available for my MouseHook to process.
Looks like another A2003 bug. If you set the TextBox Top or Bottom
Margin props then Vertical ScrollBar will not appear! I've reported the
bug. For now simply leave off the Margin settings.
:-)
--
HTH
Stephen Lebans http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"deko" <no****@hotmail.com> wrote in message
news:NZ*******************@newssvr25.news.prodigy. com... BTW, what version of Access are you using?
Access 2003
updated mdb on the way...
> When you mentioned the Vertical ScrollBar was not visible this was obviously the problem. With no Vertical ScrollBar there are no MouseWHeel messages available for my MouseHook to process. Looks like another A2003 bug. If you set the TextBox Top or Bottom Margin props then Vertical ScrollBar will not appear! I've reported the bug. For now simply leave off the Margin settings. :-)
yep, that was it... I set the textbox margins to 0 - now the mouse wheel
works and the scrollbar is there. I'll keep an eye out for the KB article
:)
Thanks again for the help. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bill H |
last post by:
I used a bit of JS on a page that is fairly long and didn't like the
way that
<A HREF='#' ONCLICK=\"...
refreshed the page to the top. Removing the HREF (<A ONCLICK=\"...)
solved my...
|
by: PeP |
last post by:
Good morning,
I have a form containing a text-area,
I'd like to know if it exists a function that, when I activate an event,
returns the position of the cursor in the text-area.
For example, I...
|
by: oketz1 |
last post by:
Hi
I am writing an application very similar to notepad and I have to
implement the status bar feature, which mean that I have to follow
after the cursor
is there any event that raised when...
|
by: Marty Cruise |
last post by:
Does anyone know of an wait-type cursor that can show text beside the
hourglass? I'd like to display status messages beside the hourglass while
not allowing the user to click anything...
|
by: Netkiller |
last post by:
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Project: Network News Transport Protocol Server Program
Description:
基于数据库的新闻组,实现BBS前端使用NNTP协议来访问贴子...
|
by: David Veeneman |
last post by:
I'm creating a UserControl that uses a LinkLabel. For reasons that I won't
bore everyone with, I don't want the LinkLable to show the default hand
cursor when the mouse enters the control. Should...
|
by: Frinavale |
last post by:
I am just wondering if it is possible to determine where the cursor is located within an <input type='text'> element using JavaScript?
I'd like to write a snippet of code that will move to the...
|
by: =?Utf-8?B?anAybXNmdA==?= |
last post by:
We have some dumb and lazy people here, so I need help.
To fix the dumb part: We have placed MaskedTextBoxes on the forms so they
will stop entering the information incorrectly.
Now the lazy...
|
by: michels287 |
last post by:
Right now I have a touchscreen with a virual keyboard.
I would like to create arrow keys. If the user messed up the inputted text, he can move the blinking cursor left one space at a time between...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
| |