Results 1 to 7 of 7
  1. #1
    Bubi is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    8

    Form_Current Event


    Hi,
    I set up a Form_Current event for subform with intention to whenever user clicks on one of the records in subform the form_Current Event is triggered and a certain procedure runs.
    The problem is if I open form and click on the very first record Form_Current event is not triggered (see picture Form_Current_Event_1.jpeg).
    If I click on the second record (see picture Form_Current_Event_2.jpeg), Form_Current event triggers, and if I go back to first one again Form_Current triggers as it should. I usually work around fine if I have more records, but in case where there is just one, Form_Current event doesn't want to trigger at all.

    Does anyone have any suggestion on how to solve this problem?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The current event for the first record should be firing when the form opens. I just tested on a form/subform and the subform's current event indeed fired as the form opened.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Bubi is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    8
    Thank you for the input. After reading you reply I came to an idea, but found out soon that it cannot work in all possible cases
    Do you think there is some other solutions to my problem. I need this event to be triggered only by clicking on the record.
    Maybe there is some other event except OnCurrent that I could use for this purpose, but I just don't seem to see it.

    Thanks

  4. #4
    Bubi is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    8
    I tried to put my procedure in OnGotFocus event and it triggers when I click on the first record. I thought that was my problem, but now I see that actually if I click on first record (as shown in picture 1) my Form.SelHeight is still equal 0

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    What is it you're trying to accomplish with the code?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Bubi is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    8
    Once the user click on the record, my code finds out which record it is and transfer its data to certain fields.
    So here is my code that I want to call when user clicks on record. It works great if the first clicked record is not the first one.
    If it is the first one and my code got called then F.SelHeight = 0 and F.SelTop = 1.
    But if I click the second one then F.SelHeight = 1 and F.SelTop = 2.
    Then I go back and click the first one and F.SelHeight = 1 and F.SelTop = 1
    Code:
    Case "Contact_Address"
    If DetailContact Then
    Set F = Forms!DetailContact!ContactAssignedAddress.Form
    Else
    Set F = Forms!frmDatabaseDesktop!sfrmWorkspace.Form!ContactAssignedAddress.Form
    End If
    Set rs = F.RecordsetClone
     
    If rs.RecordCount <> 0 Then
    'Move to the first record in the recordset.
    rs.MoveFirst
    'Move to the first selected record.
    rs.Move F.SelTop - 1
     
    If F.SelHeight = 1 Then
    Set rst = New ADODB.Recordset
    Set cn = New ADODB.Connection
    'Open connection to SQL Server
    cn.Open strOLEDBConnect
    cn.CursorLocation = adUseClient
     
    rst.Open "SELECT * FROM dbo.Contact_Address WHERE ContAddressID = " & rs![ContAddressID], cn
     
    If DetailContact Then
    SetValuesContact_Address Forms!DetailContact, rst
    Else
    SetValuesContact_Address Forms!frmDatabaseDesktop!sfrmWorkspace.Form, rst
    End If
    ElseIf SelHeight > 1 Then
    MsgBox "Can't edit more then one record at a time!"
    End If
    Set cn = Nothing
    Set rst = Nothing
    End If

  7. #7
    Bubi is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    8
    Hi,

    here is the update on my case for those that might be interested.

    When clicking on the record my procedure has been called from Form_Current event. In the procedure, SelHeight Property was supposed to be set to 1 and SelTop to 0 for the first column. But in my case it was SelHeight = 0 and SelTop = 0, and that is why it did not work whenever I would select first record for the first time.
    I moved the procedure call to Form_OnClick event and now it works like I want it to work. SelHeight = 1 and SelTop = 0 for the first record.

    Thanks to all.

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

Similar Threads

  1. Before Update Event
    By randolphoralph in forum Programming
    Replies: 0
    Last Post: 06-15-2010, 09:26 AM
  2. Event Stopping - need help please
    By TG_W in forum Forms
    Replies: 3
    Last Post: 05-20-2010, 09:25 AM
  3. OnClick event
    By HotTomales in forum Forms
    Replies: 1
    Last Post: 12-24-2009, 08:10 PM
  4. Replies: 21
    Last Post: 06-03-2009, 05:54 PM
  5. form_current event question
    By edo in forum Forms
    Replies: 0
    Last Post: 09-08-2008, 02:54 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