473,385 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Lock Form Question Access

19
Hi,

A quick question here on how to prevent my mouse scroll wheel from being able to track through all previously saved records in my table. Any idea's?

Peader
Nov 2 '07 #1
6 2197
missinglinq
3,532 Expert 2GB
If you're running Access 2007, you already have a function that addresses this issue! Just check with Help.

For all other versions, you'll need some outside help. A gentleman by the name of Stephen Lebans has a sample database that does this and can be downloaded at:

http://www.lebans.com/mousewheelonoff.htm

First, download and unzip the db and take a look. Go into your db and goto File > External Data > Import and import the module modMouseHook from the sample database. Next make sure you have the included file, MouseHook.dll, in the same folder your database resides in. The following code needs to run before the mousewheel will be locked:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  ' Turn off Mouse Scroll
  3.  blRet = MouseWheelOFF
  4.    End Sub
If you have one form that always loads first in your db, place the code there. If the first form to load varies, place the same code in each form. You should now be set!

Linq ;0)>
Nov 2 '07 #2
Rabbit
12,516 Expert Mod 8TB
I developed this method recently so I didn't have to use Leban's dll.
It's definitely more work to incorporate than his dll.
It's a more hardcore approach in that it locks all methods of navigating records except for custom buttons. This means the default navigation buttons don't work. The mousewheel doesn't work. Tabbing through to the next record doesn't work. Although I suppose the code could be modified to allow tabbing to work.

Edit: Now that I think about it, it's probably possible to lock only the mousewheel using a similar concept.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3. Dim BkMk As Variant
  4. Dim AllowMove As Boolean
  5. Dim IsNewRec As Boolean
  6.  
  7. Private Sub but_MoveNext_Click()
  8. On Error GoTo Err_but_MoveNext_Click
  9.  
  10.     AllowMove = True
  11.     DoCmd.GoToRecord , , acNext
  12.     BkMk = Me.Bookmark
  13.     IsNewRec = False
  14.  
  15. Exit_but_MoveNext_Click:
  16.     AllowMove = False
  17.     Exit Sub
  18.  
  19. Err_but_MoveNext_Click:
  20.     If Err.Number = 3021 Then
  21.         IsNewRec = True
  22.     Else
  23.         If Err.Number <> 2105 Then MsgBox Err.Number & ": " & Err.Description
  24.     End If
  25.     Resume Exit_but_MoveNext_Click
  26.  
  27. End Sub
  28.  
  29. Private Sub Form_Current()
  30.     If Not AllowMove Then
  31.         If IsNewRec Then
  32.             DoCmd.GoToRecord , , acNewRec
  33.         Else
  34.             Me.Bookmark = BkMk
  35.         End If
  36.     End If
  37. End Sub
  38.  
  39. Private Sub Form_Load()
  40.     BkMk = Me.Bookmark
  41.     AllowMove = False
  42.     IsNewRec = False
  43. End Sub
  44.  
  45. Private Sub but_MovePrior_Click()
  46. On Error GoTo Err_but_MovePrior_Click
  47.  
  48.     AllowMove = True
  49.     DoCmd.GoToRecord , , acPrevious
  50.     BkMk = Me.Bookmark
  51.     IsNewRec = False
  52.  
  53. Exit_but_MovePrior_Click:
  54.     AllowMove = False
  55.     Exit Sub
  56.  
  57. Err_but_MovePrior_Click:
  58.     If Err.Number <> 2105 Then MsgBox Err.Number & ": " & Err.Description
  59.     Resume Exit_but_MovePrior_Click
  60.  
  61. End Sub
  62.  
  63. Private Sub but_AddNew_Click()
  64. On Error GoTo Err_but_AddNew_Click
  65.  
  66.     AllowMove = True
  67.     DoCmd.GoToRecord , , acNewRec
  68.     IsNewRec = True
  69.  
  70. Exit_but_AddNew_Click:
  71.     AllowMove = False
  72.     Exit Sub
  73.  
  74. Err_but_AddNew_Click:
  75.     If Err.Number <> 2105 Then MsgBox Err.Number & ": " & Err.Description
  76.     Resume Exit_but_AddNew_Click
  77.  
  78. End Sub
  79.  
Nov 2 '07 #3
Peader
19
Thanks Lads,

Problem solved. I used Lebans method.

Peader
Nov 3 '07 #4
missinglinq
3,532 Expert 2GB
Glad we could help!

Linq ;0)>
Nov 3 '07 #5
Hi all,

Just tried the Lebans one and it doesn't work for me...don't know what I'm doing wrong. Unless using the scroller on my laptop's trackpad isn't covered by the code??

I put the .dll in the same folder as the sample db (desktop)

Any advice..?

Thanks
Taz
Nov 15 '07 #6
missinglinq
3,532 Expert 2GB
Never seen a scroller on a trackpad, but the most common mistake people make is forgetting to import the module modMouseHook from the sample database into their own database.

Welcome to TheScripts!

Linq ;0)>
Nov 15 '07 #7

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

Similar topics

2
by: Roy Padgett | last post by:
I have a combo box where users select the customer name and can either go to the customer's info or open a list of the customer's orders. The RowSource for the combo box was a simple pass-through...
7
by: Sunny | last post by:
Hi, I can not understend completely the lock statement. Actally what is locked: 1. the part of the code between {...} or 2. the object in lock() In the docs is written: for 1: The lock...
3
by: Invalid | last post by:
I launch a worker thread that periodically reads a volatile bool abortRequested, which could be set to true by my main form. IOW, there is one thread that can read that bool and one different...
0
by: Nashat Wanly | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaskdr/html/askgui06032003.asp Don't Lock Type Objects! Why Lock(typeof(ClassName)) or SyncLock GetType(ClassName) Is Bad Rico...
7
by: Thomas Nielsen [AM Production A/S] | last post by:
Hi, I have one web form (WebForm1.aspx) from which i would like to display the output of another web form, WebForm2.aspx, in a controlled environment. I do this by using HttpWebRequest to...
8
by: nytimescnn | last post by:
I've read some discuession about lock() for thread-safe. I am wondering what will be the differce between below two code segment? Code 1: class A { private static Object padlock = new...
5
by: payffl | last post by:
My users are running Access '03. They have a database with a form that allows them to enter new records. Frequently they will move to a new record and not enter any information. This prevents...
94
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock...
5
by: prakashwadhwani | last post by:
The Delete Event/Proc & "Save_Fields_In_Form_Header" Event/Proc in my form were working perfectly. However, after I added a call to the "Save_Fields_In_Form_Header" Event/Proc in the...
25
by: zmickle | last post by:
Excuse my noobness. I am managing an access database that is shared by 4 users. Management does not want to use any technologies outside of access for this application (no SQL Server, etc). I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
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...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.