Results 1 to 4 of 4
  1. #1
    Join Date
    May 2002
    Posts
    157

    Unanswered: Clearing an Unbound Field of details when I press ESC

    I have a form called ClientCaseNotesForm which opens up to a new record.

    It has a field called [ClentID]

    Also on this form is an unbound field called [ProgramLU] which has a select statement as follows:

    SELECT ClientProgramReferral.ProgramID, ClientProgramReferral.ClientID, ProgramDetails.ProgramName, ProgramDetails.DeptName, ClientProgramReferral.DateReferred, ClientProgramReferral.DateReferralEnded, ClientProgramReferral.ClientID, ClientProgramReferral.ProgramID, ClientProgramReferral.DateReferred
    FROM ClientProgramReferral INNER JOIN ProgramDetails ON ClientProgramReferral.ProgramID = ProgramDetails.ProgramID
    WHERE (((ClientProgramReferral.ClientID) Like [Forms]![ClientCaseNotesForm]![ClientID]))
    ORDER BY ClientProgramReferral.ClientID, ClientProgramReferral.ProgramID, ClientProgramReferral.DateReferred;


    When I open this form the [ProgramLU] is blank. When I select a [ClientID] the unbound [ProgramLU] does not display the details relating to the Client (as per the select statement). So I added in the following code which has fixed this problem (now when I select a [ClientID] the [ProgramLU] shows the details).

    Private Sub ClientID_Exit(Cancel As Integer)
    Forms!ClientCaseNotesForm.ProgramLU.Requery
    End Sub


    My problems is that when I click on the escape button to undo any fields I have entered on the form, the [ProgramLU] still retains the details of the last client selected. I would like to see this return back to showing nothing.

    I have spent a lot of time trying to achieve this without success. Can anyone please provide some advice?

    Thanks heaps

    Karen Day

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Karen,

    You can set the KeyPreview property of the form to True and use some code in the KeyPress event of the same form:
    Code:
    Private Sub Form_KeyPress(KeyAscii As Integer)
    
        If KeyAscii = 27 Then    ' 27 is the code for Escape
        
            ' some code to reset the subform
            
        End If
        
    End Sub
    Have a nice day!

  3. #3
    Join Date
    May 2002
    Posts
    157
    Thanks heaps works perfectly

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome !
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •