Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Retstricting Characters During Data Entry

Discussion in 'Information Technology' started by Boz, Oct 28, 2005.

  1. Boz

    Boz
    Expand Collapse
    Guest

    Current version is Access 97. I have a field "Probill Number". This field
    is used on several different forms and queries to update information as loads
    are scheduled, received, and closed. It is also linked to another database
    that tracks productivity using the Probill field. The problem I am having is
    that when the Probill is first entered (scheduled) in the system, if the
    clerk accidently hits the spacebar before typing, it becomes next to
    impossible for others to access that record as needed. The last thing I want
    is for people to start accessing the tables to try to find records.

    I thought of using an input mask, but unfortunately the Probill number can
    be anywhere from 6 to 12 characters long.

    Any help in solving this problem would be greatly appreciated.
     
  2. Loading...

    Similar Threads Forum Date
    Sikh characters in famous movies Questions and Answers Jul 15, 2014
    Sikh News New Comic Book Coming out With Sikh Characters Breaking News Dec 22, 2005

  3. Van T. Dinh

    Van T. Dinh
    Expand Collapse
    Guest

    Use the Control_BeforeUpdate Event to check whether the value / data entry
    starts with a blank space and if so, post a MsgBox and cancel the update by
    setting Cancel = True.

    Check Access VB Help on the BeforeUpdate Event of a Control / TextBox.

    --
    HTH
    Van T. Dinh
    MVP (Access)



    "Boz" <Boz@discussions.microsoft.com> wrote in message
    news:E59C8EAD-1B38-42CB-99F8-DF312F6A9FEC@microsoft.com...
    > Current version is Access 97. I have a field "Probill Number". This
    > field
    > is used on several different forms and queries to update information as
    > loads
    > are scheduled, received, and closed. It is also linked to another
    > database
    > that tracks productivity using the Probill field. The problem I am having
    > is
    > that when the Probill is first entered (scheduled) in the system, if the
    > clerk accidently hits the spacebar before typing, it becomes next to
    > impossible for others to access that record as needed. The last thing I
    > want
    > is for people to start accessing the tables to try to find records.
    >
    > I thought of using an input mask, but unfortunately the Probill number can
    > be anywhere from 6 to 12 characters long.
    >
    > Any help in solving this problem would be greatly appreciated.
     
  4. Dirk Goldgar

    Dirk Goldgar
    Expand Collapse
    Guest

    "Van T. Dinh" <VanThien.Dinh@discussions.microsoft.com> wrote in
    message news:encPwG22FHA.3788@tk2msftngp13.phx.gbl
    > Use the Control_BeforeUpdate Event to check whether the value / data
    > entry starts with a blank space and if so, post a MsgBox and cancel
    > the update by setting Cancel = True.
    >
    > Check Access VB Help on the BeforeUpdate Event of a Control / TextBox.


    Or just use the AfterUpdate event of the text box to trim leading spaces
    from the value. For example,

    Private Sub Probill_Number_AfterUpdate()

    Me![Probill Number] = Trim(Me![Probill Number])

    End Sub

    --
    Dirk Goldgar, MS Access MVP
    www.datagnostics.com

    (please reply to the newsgroup)
     
  5. Larry Linson

    Larry Linson
    Expand Collapse
    Guest

    "Boz" <Boz@discussions.microsoft.com> wrote

    > . . . The problem I am having is that when
    > the Probill is first entered (scheduled) in the system,
    > if the clerk accidently hits the spacebar before typing,
    > it becomes next to impossible for others to access
    > that record as needed. The last thing I want is for
    > people to start accessing the tables to try to find records.
    >
    > I thought of using an input mask, but unfortunately
    > the Probill number can be anywhere from 6 to 12
    > characters long.


    If you simply want to disallow spaces in the "Probill Number", in the
    KeyPress Event for the TextBox into which the data is being entered, put:

    If KeyAscii = 32 Then
    KeyAscii = 0
    End If

    If you only want to disallow spaces at the beginning, then use this code but
    substitute the name of your TextBox for <textbox>

    If Len(Me.<textbox>.Text) = 0 Then
    If KeyAscii = 32 Then
    KeyAscii = 0
    End If
    End If

    But, if you have others entering the whole Probill Number, I'd suggest, for
    those Forms other than the one where it is initially entered, instead of
    just giving them a Text Box to type it in, give them a ComboBox that has its
    LimitToList property set to yes, with a RowSource of the valid Probill
    Numbers in the system. It will scroll as they type (unless you have set the
    AutoExpand property to No, which you don't want to do in this case) each
    character, and at some point they may see the whole number and be able to
    click to choose it.

    (Never make the user do extra work, especially if you can help them avoid
    making errors while you are, potentially, saving them some keystrokes.)

    Larry Linson
    Microsoft Access MVP
     

Share This Page