Results 1 to 4 of 4
  1. #1
    fcbuek is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    6

    Setting a constant in the text field

    Hi,


    I have a question for my input mask in the text field I have set to:

    Code:
    AAAA"/"AAAAAAAA"/"A
    Input mask:
    Code:
    "    /        / "
    I have a question, is there any way I can use VBA or somehow change the input mask to set permanently three 0 to 5 positions
    [/CODE]
    Input mask I would like to get:
    Code:
    "    /000     / "
    because I noticed when entering data into this field that they always repeat themselves. I tried to use, but the zeros in the field are not recorded in the table

    Code:
    AAAA"/000"AAAAA"/"A
    Thank you in advance for your help

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    the / won't be included either

    suspect it wont work but you could try

    AAA\/\0\0\0AAAAA\/A

    but usually better to split your value into it's component parts and store separately - they can be concatenated for display purposes as required.

    Reason I suspect it won't work is that input masks are about limiting user input, not creating characters to automatically include in your value - for that you would use vba in the control after update event.

    something like

    mycontrol=left(mycontrol,3) & "/000" & mid(mycontrol,4,4) & "/" & right(mycontrol,1)

    another way may be to use the control change event so that when the user has entered the 3rd character vba automatically adds "/000"

  3. #3
    fcbuek is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    6
    I tried to apply and it also doesn't work
    Code:
    Private Sub Number2_AfterUpdate()
    mycontrol = Left(mycontrol, 3) & "/000" & Mid(mycontrol, 4, 4) & "/" & Right(mycontrol, 1)
    End Sub

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    it wont since you are referencing 'mycontrol' not the name of your control

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

Similar Threads

  1. Setting a constant caption for all forms
    By DubCap01 in forum Forms
    Replies: 5
    Last Post: 01-10-2015, 03:39 PM
  2. Replies: 1
    Last Post: 11-28-2014, 02:42 PM
  3. Replies: 1
    Last Post: 03-27-2014, 06:42 AM
  4. divide value by a constant and populate same field
    By ridgeview80 in forum Queries
    Replies: 5
    Last Post: 05-28-2012, 09:37 AM
  5. Setting a field to only accept text characters, not numbers
    By USAFA2012 in forum Database Design
    Replies: 2
    Last Post: 03-09-2010, 12:37 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