Results 1 to 9 of 9
  1. #1
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389

    Set focus not working properly

    Good Morning to all experts......
    I have created a main form and a sub form. both of there names are:----

    main form - offer_entry
    sub form - grey_shade

    after this i have written an event in the save button that if the save form is empty then the data should not be saved and blink the cursor in the shade name text box of the sub form.
    with this code, the focus is on the text box of the sub form, but the cursor is not blinking, the cursor remain hidden and it is exposed after pressing shift+tab key, please give your opinion to all the experts.

    If DCount("*", "GREY_SHADE", "ID = " & Me.ID) < 1 Then
    MsgBox ("PLEASE ENTER SHADE")


    Me.GREY_SHADE!SHADE.SetFocus

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,997
    Where is that code?, in the main form?
    If so, that is not the correct syntax.

    Forms: Refer to Form and Subform properties and controls
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    thanks for reply,
    this code is written in save button
    i tried it with the other code you mentioned but problem is still the same
    the cursor definitely goes there but remain hidden, it does not show with blinking


    old code

    Private Sub SAVE_Click()

    Set DB = CurrentDb
    Set RST = DB.OpenRecordset("GREY_OFFER")
    If DCount("*", "GREY_SHADE", "ID = " & Me.ID) < 1 Then
    MsgBox ("PLEASE ENTER SHADE")
    Me.GREY_SHADE!SHADE.SetFocus

    Exit Sub
    End If
    end sub

    Tried this too-
    Me!GREY_SHADE.Form.ID.SetFocus (in place of "Me.GREY_SHADE!SHADE.SetFocus")

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,997
    Add a dummy textbox control and try and set focus to that. This is for testing purposes only.
    If the cursor is then blinking, then some property on your Shade control is preventing it from blinking.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    No, still the same problem...

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,997
    Quote Originally Posted by deepaksharma View Post
    No, still the same problem...
    Try a repair of Office then.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    i solve it after add this code :-)

    sendkeys "+{tab}"

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,997
    Quote Originally Posted by deepaksharma View Post
    i solve it after add this code :-)

    sendkeys "+{tab}"
    That is a workaround, not a solution?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    yes there is no other solution....

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

Similar Threads

  1. DCOUNT not working properly
    By smaier in forum Programming
    Replies: 3
    Last Post: 08-20-2021, 06:52 PM
  2. Replies: 28
    Last Post: 01-24-2018, 05:14 PM
  3. Checkboxes not working properly
    By TK03 in forum Access
    Replies: 1
    Last Post: 12-24-2012, 09:04 AM
  4. UDF Referencing Excel Not Working Properly
    By JoeM in forum Programming
    Replies: 7
    Last Post: 09-27-2012, 12:20 PM
  5. Count or DCount Not Working Properly
    By Chris1112 in forum Forms
    Replies: 3
    Last Post: 05-09-2012, 02:51 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