Results 1 to 6 of 6
  1. #1
    Bigdoggit is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    27

    Ignore user input while code is running

    How can I cause the form to ignore user input while code is running? It won't be for long. I have several unbound controls. I am using the LostFocus event to trigger a db.Execute command which saves data from that single control into the database. This is to deal with random record locking. I have already split the database, each person has their own front end, moved memo fields into their own tables, etc. but the locks are still there. Our stop gap measure is to not let people update as often. Long term I am hoping small SQL UPDATE commands will fix this. However, I would like to stop a person from doing anything on the form while to SQL statement is executed because I have some people who like to move fast and if they move too fast they will get a message about the data changing since their last save even though they are the one making all changes.



    I have tried a separate form opening as modal and then closing to block user input, but this causes extra lostfocus and gotfocus events to appear for the original form control(s) so that idea is not working.

    Thank you in advance

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by Bigdoggit View Post
    I would like to stop a person from doing anything on the form while to SQL statement is executed
    the way I see it, you can do it a number of ways. First of all, which is probably not known to many, there is API code to block the keyboard and mouse:
    Code:
    Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long
    To BLOCK, the arg is 1, to UNBLOCK the arg is 0. and of course, the return values of the function are also 0 and 1 indicating what the status of the hardware items are.

    and then course another way to do it, which requires less care, is simply to popup a modal for with a stopwatch function or something to show them that the code is running, and close it at the end of the execution.

    Modal forms disallow users to manipulate windows below that one, so that's probably easiest.

  3. #3
    Bigdoggit is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    27

    Modal forms don't work

    I tried modal a modal form first. However, when I close it it triggers the gotfocus and lostfocus control events that trigger saving data in the first place. The block API might work. I was just telling someone that I needed to spend more time working with Windows API calls. I will investigate that on Monday and see where I can get.

  4. #4
    Bigdoggit is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    27

    Checked it out today thankfully

    Well, I am pleased so far. I implemented this and it seems to have sovled my problem. I knew it could be done so thank you for guiding me right to the water. For anyone viewing this form the 'Declare' portion provided can be made Public instead of Private and then put in a module other than a form module so it can be called from anywhere in your project. Inside a form module even public functions are not seen outside of the form (or at least I am operating under that belief). Then, when you want to block input just add:

    Call BlockInput = 1

    to block input or

    Call BlockInput = 0

    to unblock input.

    Thanks again for the help

  5. #5
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    OK. marked as solved.

  6. #6
    Bigdoggit is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    27

    Hopefully this thread is still being watched

    I found a problem from the BlockInput idea. I run the Execute method to update data in the Access database. If input is blocked before this code is run then once input is unblocked the control being moved to is in some sort of text select mode. I have opened a new thread on this topic under Access Forms. Help is appreciated.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Criteria issue when using user input and > < ect
    By scotty562 in forum Queries
    Replies: 3
    Last Post: 11-11-2010, 11:08 AM
  2. Reporting with user input
    By tazbergy in forum Reports
    Replies: 1
    Last Post: 09-12-2010, 11:26 PM
  3. User Input Query
    By ManC in forum Queries
    Replies: 2
    Last Post: 03-04-2010, 07:09 PM
  4. Chart with user input
    By mungyun in forum Access
    Replies: 1
    Last Post: 12-28-2009, 07:44 PM
  5. Set required user input
    By ZeusOsiris in forum Database Design
    Replies: 2
    Last Post: 12-04-2006, 07:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums