Results 1 to 4 of 4
  1. #1
    f15e is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2016
    Posts
    71

    Datasheet Subform Select Records & the Current event

    I've looked many places without an answer but I am having an issue with clicking my record selector in my datasheet subform and it doesn't fire on the first click but does every time after. I am using the Current event. I have 3 buttons: ADD, EDIT, DELETE. I have no issues with ADD because I'm not using the Current event for it. If I click either EDIT or DELETE button, a text box pops up above my datasheet. I don't allow the user to edit in the datasheet itself. Instead I want them to select a record where the record field (i.e. cell) value is populated in the textbox where they can then edit or choose to delete the value from the database. It works with the exception of the first click on the datasheet record not working, but does there after.



    A brief explanation of the code I believe where the problem lies. I can post more if needed but maybe someone knows right of hand what the issue is.
    I click either EDIT or DELETE button. Textbox pops up over datasheet where as the user clicks a record, a specific chosen field value in that record shows up in the textbox. First click, nothing happens. Textbox is empty. 2nd click and after the correct value is shown in the textbox. If user wants to edit a value, he does so in the textbox and clicks save where it is updated in the table. If wants to delete value, clicks confirm delete with warning message. So on and so forth where value is deleted from table. I have no issues with updating, deleting, or adding values to the table, it's just that pesky first click that does nothing that is bothering me.

    Current Event code within my subform:

    '************************************************* *******************************
    ' This sub is part of my datasheet subform.
    Private Sub Form_Current()

    If Sel_Btn = "edit" Or Sel_Btn = "delete" Then

    Dim tmp_area_sel As String

    If Not (Me.Form.Recordset.EOF And Me.Form.Recordset.BOF) Then
    With Me.Form.Recordset
    Me.tmp_area_txtbx = .Fields("Area")
    End With
    End If

    tmp_area_sel = Me.tmp_area_txtbx

    ' Sends the selected value, captured in hidden textbox within my subform footer,
    ' to my parent form where the value is shown in my textbox
    Call Me.Parent.Send_Selection(tmp_area_sel)

    End If

    End Sub
    '************************************************* *******************************

    Thanks in advance everyone!!

  2. #2
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Bit confused. I think record selectors on a form/subform datasheet setup are on the main form only and don't show up on the subform regardless of the setting. Yet you say the subform type is datasheet? That makes me wonder what Current event; main form, subform, subform control, form control? I think if you put the code in the same event but on the subform control it should work first time.
    Last edited by Micron; 12-22-2016 at 06:39 PM. Reason: spelin and clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    f15e is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2016
    Posts
    71
    Thanks for your reply Micron. You are correct. I should not have used the term record selector. What I meant were the tabs located on the left of the subform datasheet that can be clicked to highlight that specific record. See pic.
    Click image for larger version. 

Name:	Access_Subform_Datasheet.png 
Views:	5 
Size:	11.7 KB 
ID:	26812
    The background, green section, is the parent form and the Current event is part of the datasheet subform. Does that help clear it up?
    Attached Thumbnails Attached Thumbnails Access_Subform_Datasheet.png  

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    If you put the code on the subform control as mentioned it should work. Not the subform. IIRC the control gets the focus first, then the subform, which is why it takes two clicks.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 7
    Last Post: 06-17-2015, 07:12 PM
  2. Replies: 2
    Last Post: 04-08-2015, 04:06 PM
  3. Replies: 3
    Last Post: 01-14-2015, 02:51 PM
  4. Replies: 8
    Last Post: 08-26-2012, 11:11 PM
  5. Replies: 5
    Last Post: 02-06-2012, 03:58 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