[AccessD] Blanks in text box

A.D.TEJPAL adtp at airtelbroadband.in
Wed Nov 14 00:03:05 CST 2007


Rocky,

    Were you able to try the solution given in my post of 13-Nov-2007 ?

A.D.Tejpal
------------

  ----- Original Message ----- 
  From: A.D.TEJPAL 
  To: Access Developers discussion and problem solving 
  Cc: A.D.TEJPAL 
  Sent: Tuesday, November 13, 2007 20:24
  Subject: Re: [AccessD] Blanks in text box


  Rocky,

      You wish to trap the trailing spaces in a text box, while using its contents for applying filter. This calls for certain special measures as trailing spaces (if any) get lost while exiting the text box.

      Sample code in form's module, as given below, demonstrates application of filter on a subform, duly taking into account the contents of text box (including trailing spaces if any) located on the parent form.

  Best wishes,
  A.D.Tejpal
  ------------

  Sample code in form's module
  Txt1 is the name of text box where criteria string is
  entered. SF_Sub is the name of control holding the
  subform. Clicking command button named CmdFilter
  applies filter on subform records - duly taking into
  account the trailing blanks (if any) in text box Txt1
  PCode is the name of field on which filter is applied.
  '=================================
  ' Declarations section
  Private RefTxt As String
  '--------------------------------------------------

  Private Sub CmdFilter_Click()
      With Me.SF_Sub.Form
          .Filter = "PCode Like '" & RefTxt & "*'"
          .FilterOn = True
      End With
  End Sub
  '--------------------------------------------------

  Private Sub Txt1_Change()
      RefTxt = ActiveControl.Text
  End Sub
  '--------------------------------------------------

  Private Sub Txt1_Enter()
      RefTxt = ActiveControl.Text
  End Sub
  '=================================


    ----- Original Message ----- 
    From: Rocky Smolin at Beach Access Software 
    To: 'Access Developers discussion and problem solving' 
    Sent: Tuesday, November 13, 2007 07:17
    Subject: Re: [AccessD] Blanks in text box

    It the text box where I want to have the trailing blanks retained. I'm
    setting the filter for the text box in a subroutine that's called from the
    Change event of the text box.

    Rocky

    -----Original Message-----
    From: accessd-bounces at databaseadvisors.com
    [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust
    Sent: Monday, November 12, 2007 4:59 PM
    To: Access Developers discussion and problem solving
    Subject: Re: [AccessD] Blanks in text box

    What is the "it" that won't accept and retain trailing blanks, Rocky, the
    list box, the textbox, the filter, or what?  If you're trapping keystrokes,
    make sure you aren't including a Trim in there somewhere.

    Charlotte Foust

    -----Original Message-----
    From: accessd-bounces at databaseadvisors.com
    [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin at
    Beach Access Software
    Sent: Monday, November 12, 2007 4:24 PM
    To: 'Access Developers discussion and problem solving'
    Subject: [AccessD] Blanks in text box

    Dear List:
     
    I am trapping keystrokes in a text box and setting a filter in a list box
    based on the current value in the text box.  But it won't accept and retain
    trailing blanks.  If my client wants to search on R & R for example, he
    presses R and the list box of names is filtered to all those beginning with
    R.  if he then presses the space bar, it should show all the name beginning
    with R-blank.  But of course, it strips the trailing blank.
     
    Is there some trick to getting the trailing blanks to be included in the
    string?
     
    MTIA
     
    Rocky


More information about the AccessD mailing list