Results 1 to 3 of 3
  1. #1
    Milade8080 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    18

    Field adjustment under certain conditions

    How do I set a field to the table so that it will accept only the number 0 or a 12-digit number


    Can someone advise me??

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    I would do this via my form. Example:

    'Purpose: Not allow more than 12 characters
    If Len(Forms.YourFormNameHere.SomeFieldName.Text) > 12 Then
    DoCmd.Beep
    Forms.YourFormNameHere.SomeFieldName.Text = Left(Forms.YourFormNameHere.SomeFieldName.Text, 12)
    Forms.YourFormNameHere.SomeFieldName.SelStart = 12
    End If

    HTH

  3. #3
    Z1nkstar's Avatar
    Z1nkstar is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Location
    TX, USA
    Posts
    145
    in the form in which you can edit that field under after update event I would put something like this:
    Code:
    Private Sub textbox1_AfterUpdate()
    If textBox1.Text.Length <= 12 Then
    MsgBox("Must Have 12 Digits")
    TextBox1.Text = Strings.Left(TextBox1.Text, TextBox1.Text.Length - 1)
    End If
    End Sub

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

Similar Threads

  1. Clearing a field with conditions
    By Ruegen in forum Forms
    Replies: 8
    Last Post: 11-05-2013, 04:28 PM
  2. Caculated field with if then conditions
    By tmaleshafske in forum Access
    Replies: 2
    Last Post: 09-11-2012, 01:26 PM
  3. Replies: 1
    Last Post: 08-18-2012, 11:32 PM
  4. Replies: 3
    Last Post: 08-01-2012, 10:56 AM
  5. Warehouse location adjustment
    By tj63069 in forum Database Design
    Replies: 5
    Last Post: 01-11-2012, 06:19 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