Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    NISMOJim is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    273

    Should I assume that nobody understands why this isn't working the way it should?

  2. #17
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    Db received intact. I have found the procedure; all the SetFocus actions are commented out. I'll take a look. Two tables are linked and therefore missing. I'll try to recreate them if needed but I may have to get back to you and ask for samples. All data will be treated in confidence.

  3. #18
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    OK Jim, are you sitting comfortably? Then I’ll begin. (Quote: BBC Radio, ‘Listen With Mother,’ cica 1950)

    Consider:

    Code:
    Private Sub cmdSave_LostFocus()
    'Sends focus back to beginning if using Tab key
     Me.txtXacnEmpName.SetFocus
    End Sub
    I guess when you wrote this you believed that only a Tab action could move the focus away from cmdSave and did not realize that VBA’s SetFocus can do exactly the same thing. So, if a validation fails, you are attempting to move the focus to the offending control, away from cmdSave. This procedure is triggered and overrides the validation’s SetFocus action. This is why the focus always returns to the first – txtXacnEmpName – control. (I haven’t dug deep enough to explain why you get the error message but I’m confident it’s all connected.)

    So what to do? I understand why you wrote this procedure but it is not the best way to get the tabbing to move circularly around this record only.

    • First and foremost, select the form in design view and on the property sheet page go to the ‘Other’ tab. The fourth entry is ‘Cycle.’ Change the selection to ‘Current Record’ and tabbing will go round and round the current record ad infinitum. Now you may delete the cmdSave_LostFocus() procedure.
    • If you don’t want the three command buttons to be included in this circular tabbing, select them and go to the ‘Other’ tab on the property sheet. Set ‘Tab Stop’ to ‘No.’ Now your user must click on a command button; (s)he cannot tab to it.
    • If you wish to provide a keyboard route to the command button then in the caption property include an ampersand before your chosen shortcut character. For example ‘&Save’ is shown as ‘Save’ and the command button may be invoked by [Alt+S]. At the moment you are displaying bit maps on your buttons so a caption will not show unless you change the picture caption arrangement and button size (or modify your bitmap).
    • Another way of providing keyboard routes to command buttons is through the specification of a default button – activated by [Enter] – and a cancel button – activated by [Esc]. Both of these properties are found on the 'Other' tab.


    I believe all should work for you now. Uncomment the SetFocus actions and delete or comment out the On Error statements.

  4. #19
    NISMOJim is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    273
    Wow! I knew it had to be something stupid on my part! Thank you so much for the help, it's working perfectly. I had forgotten all about the LostFocus procedure. I don't remember why I tried it that way, but it didn't work how I was thinking anyway, out of sight out of mind. I believe I had seen someone else's database able to use the tab key to scroll through the controls. When it got to the Save button, it would act like a click instead of going back to the first control. I couldn't make that happen, so I quit trying. Anyway, thanks again!!

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. setfocus on an textbox different way
    By white_flag in forum Access
    Replies: 0
    Last Post: 09-21-2011, 05:04 AM
  2. setfocus on an textbox
    By white_flag in forum Access
    Replies: 2
    Last Post: 09-21-2011, 04:16 AM
  3. SetFocus problem
    By JvdP in forum Forms
    Replies: 0
    Last Post: 03-16-2011, 08:55 AM
  4. SetFocus Problem
    By ColPat in forum Programming
    Replies: 2
    Last Post: 06-21-2010, 04:43 AM
  5. SetFocus Issue
    By Sinjin in forum Access
    Replies: 0
    Last Post: 02-14-2008, 07:31 AM

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