Results 1 to 5 of 5
  1. #1
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68

    Question Coding data validation for a decimal .89 for form field

    If IsNumeric(Me.TxtActualBenchmark) = "False" _
    And txtBenchmarks.Value = "89% of free/reduced applicatin measured at month end" Then


    Me.TxtActualBenchmark.Undo
    MsgBox "Please enter a decimal", _
    vbInformation, "Missing Information"
    Exit Sub
    End If


    The answer needs to be .## so the conditional formatting in my report will work. How can I force the user to put a decimal with his answer? The department head wants a validation on every benchmark in my form and the results vary. So I realize If IsNumeric would not work. If I get this right I may almost be finished.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    If it matters, "application" is misspelled in the text. Could use: txtBenchmarks Like "89%*"

    Could try setting Validation Rule property for textbox: <0
    And set the Validation Text property for whatever message you want.
    Then Access will nag the user until they get it right.

    Is this also required data? Set the field in table as required and again, Access will nag the user until they enter data. Or use code in form BeforeUpdate event to determine if data entered and if not, cancel the update and return user to the record.
    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
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Your code and your explanation, taken together, is somewhat confusing to me; that's probably just me, but in answer to your question:

    How can I force the user to put a decimal with his answer?
    you can use the BeforeUpdate event that June7 mentioned:

    Code:
    Private Sub txtBenchmarks_BeforeUpdate(Cancel As Integer)
     If InStr(Me.txtBenchmarks, ".") = 0 Then
       MsgBox "Please enter a decimal", vbInformation, "Missing Information"
       Cancel = True
       Me.txtBenchmarks = Null 
     End If
    End Sub


    And FYI, IsNumeric() returns a Boolean value, not a String, so

    IsNumeric(Me.TxtActualBenchmark) = "False"

    would need to be

    IsNumeric(Me.TxtActualBenchmark) = False

    without the Quotes.

    Linq ;0)>

  4. #4
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68
    Ah ok thank you trying it out now

  5. #5
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68
    You guys are great. The decimal code worked

    If InStr(Me.TxtActualBenchmark, ".") = 0 And Me.txtBenchmarks.Value = "89 percent of free and reduced applications measured at month end" Then
    MsgBox "Please enter a decimal", vbInformation, "Missing Information"
    Cancel = True

    Exit Sub
    End If


    Thank you Wonderful

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

Similar Threads

  1. Replies: 5
    Last Post: 01-14-2013, 03:04 PM
  2. Data Validation error on Update - date field
    By TinaCa in forum Programming
    Replies: 6
    Last Post: 09-14-2011, 04:59 PM
  3. Data Validation of another field
    By dssrun in forum Access
    Replies: 4
    Last Post: 03-22-2011, 01:09 PM
  4. simple math coding for form field??
    By RCBNewbee in forum Programming
    Replies: 7
    Last Post: 07-13-2009, 08:30 AM
  5. Referencing table data in field validation rule
    By toad848 in forum Database Design
    Replies: 3
    Last Post: 03-19-2009, 07:03 AM

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