Results 1 to 8 of 8
  1. #1
    msmit8 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    14

    Validation Help Needed

    I need help adding some validation to my accessdatabase.

    Line_of_Business field list contains:
    ·AUDIT
    ·COMMERCIAL LINES
    ·PERSONAL LINES
    ·CLAIMS DEDUCTIBLE

    Policy_Account_Number field is the field Iwould like to add validation to.
    ·If Line_of_Business = AUDIT, I would like thefield to only contain alpha and numeric text. Example = 48X12345-01-00 Set 0001
    ·If Line_of_Business = COMMERCIAL LINES, I wouldlike the field to only contain alpha and numeric text. Example = 000-000-000-00
    ·If Line_of_Business = PERSONAL LINES, I wouldlike the field to only contain alpha and numeric text. Example = 000-000-000-00
    ·If Line_of_Business = CLAIMS DEDUCTIBLE, Iwould like the field to only contain alpha and numeric text. Example = 00-000-000000



    Any help or tips in doing this would be greatlyappreciated.

    Thank you!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    What a pain - changing account number structure based on type of account!

    Could use code to change the InputMask property. Code would be needed in the form Current event as well as the Line_of_Business combobox AfterUpdate.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    msmit8 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    14
    Thanks for your reply. I'm by no means a "code writer". Do you have any suggestions in for what I need to include in the code for this? If possible, could you provide me some examples for each place you mention I need to insert code?

    Thanks again!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Something like:
    Code:
    Sub Line_Of_Business_AfterUpdate()
    Call SetMask
    End Sub
    
    Sub Form_Current()
    Call SetMask
    End Sub
    
    Sub SetMask()
    Select Case Line_Of_Business
        Case "Audit"
            strMask = "000\-00000\-00\-00;0;_"
        Case "Commercial Lines", "Personal Lines"
            strMask = "000\-000\-000\-00;0;_"
        Case "Claims Deductible"
            strMask = "00\-00\-000000;0;_"
    End Select
    Me.Policy_Account_Number.InputMask = strMask
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    msmit8 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    14
    Thanks for providing me the code and my apologies for the late response. I made some changes to my database that will require new code...I think.

    I have 5 different boxes that the entry user would select that would depend on the type.

    Click image for larger version. 

Name:	Capture.PNG 
Views:	6 
Size:	6.0 KB 
ID:	18906

    The users will enter the policy type in the "Account_Policy_Number" field. Can you help me with the code that I should use for the validation with this.

    ·
    If Claims_Deductible is selected, I would like the Account_Policy_Number field to only contain alpha and numeric text. Example = 00-000-000000
    ·If Ledger_Audit is selected, I would like the Account_Policy_Number field to only contain alpha and numeric text. Example = 48X12345
    ·If Phoenix_Audit is selected, I would like the Account_Policy_Number field to only contain alpha and numeric text. Example = 48X12345-01-00 Set 0001
    ·If CL_EP or PL_EP is selected,, I would like the Account_Policy_Number field to only contain alpha and numeric text. Example = 000-000-000-00

    Thanks in advance!

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Adapt the code example as needed. Post your attempt for analysis if you still have issue.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    msmit8 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    14
    Here is the code I entered:
    Click image for larger version. 

Name:	Code.PNG 
Views:	7 
Size:	42.1 KB 
ID:	18908

    When I try and save it, I get this message.
    Click image for larger version. 

Name:	Error.PNG 
Views:	6 
Size:	10.4 KB 
ID:	18909

    Any advice to get this to work would be greatly appreciated.

    Thanks greatly!

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    It doesn't make sense to set the input mask based on the Policy_Account_Number. Shouldn't it be Line_Of_Business determines structure of the account number mask?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Validation
    By Ashley25 in forum Access
    Replies: 6
    Last Post: 08-19-2014, 04:46 PM
  2. Help needed : Library catalogue in access format is needed
    By dealers in forum Sample Databases
    Replies: 3
    Last Post: 01-16-2014, 02:03 PM
  3. Validation
    By stefan200593 in forum Access
    Replies: 1
    Last Post: 03-25-2013, 02:32 PM
  4. Age validation
    By dolovenature in forum Programming
    Replies: 5
    Last Post: 09-01-2012, 09:21 AM
  5. validation
    By slimjen in forum Forms
    Replies: 6
    Last Post: 10-12-2011, 01: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