Results 1 to 9 of 9
  1. #1
    GregShah is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Feb 2012
    Location
    Canton, Ohio
    Posts
    68

    Post Warning upon data entry on form

    I have a form that has an estimated weight we use to quote the job. Once designs are completed, i use a form to enter the actual weight of the project. I would like to put a simple warning flag on the form so if the weight varies by more or less than 10%, it directs the person entering the data to check with estimating.



    I set up a check but it was triggered before the actual weight was entered so it was always out of range. Need a way to wait until actual is entered and then check to see if it is close enough to continue.

    Thanks,

    Greg

  2. #2
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    433
    on design view of your form, add code to the ActualWeight textbox BeforeUpdate event:
    Code:
    Private Sub txtActualWeight_BeforeUpdate(Cancel As Integer)
    ' put the estimated weight here
    ' or put it on the table
    const EstimatedWeight As Double = 1000
    dim TenPct As Double
    TenPct = EstimatedWeight * 0.1
    Cancel = [txtActualWeight] > (EstimatedWeight + TenPct)
    If Cancel
        Msgbox "Weight is more than 10% from " & EstimatedWeight 
        Exit Sub
    End If
    Cancel = [txtActualWeight] < (EstimatedWeight - TenPct)
    If Cancel
        Msgbox "Weight is less than 10% from " & EstimatedWeight 
     End If
    End Sub

  3. #3
    GregShah is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Feb 2012
    Location
    Canton, Ohio
    Posts
    68
    Thanks for the info. I use est weight with a space and actual weight for the names of these records. Can I change the code to use my values or will it not work. I remember that spaces are not good.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    While spaces are not advised, you can use your names as long as you bracket them: [est weight]
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,555
    Quote Originally Posted by GregShah View Post
    I have a form that has an estimated weight we use to quote the job. Once designs are completed, i use a form to enter the actual weight of the project. I would like to put a simple warning flag on the form so if the weight varies by more or less than 10%, it directs the person entering the data to check with estimating.

    I set up a check but it was triggered before the actual weight was entered so it was always out of range. Need a way to wait until actual is entered and then check to see if it is close enough to continue.

    Thanks,

    Greg
    Use the AfterUpdate event of the actual weight control to run your code.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    433
    see this demo. open Table1 form and enter some numbers.
    on design view of the form, check out the code on the
    Actual Weight BeforeUpdate event.
    Attached Files Attached Files

  7. #7
    GregShah is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Feb 2012
    Location
    Canton, Ohio
    Posts
    68
    Quote Originally Posted by jojowhite View Post
    see this demo. open Table1 form and enter some numbers.
    on design view of the form, check out the code on the
    Actual Weight BeforeUpdate event.
    I tried but nothing happened.

    What I would like to see is a warning if the actual fall outside of 10%.

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,555
    Quote Originally Posted by GregShah View Post
    I tried but nothing happened.

    What I would like to see is a warning if the actual fall outside of 10%.
    Works for me?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    GregShah is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Feb 2012
    Location
    Canton, Ohio
    Posts
    68
    Got it. Unblocked macros and works fine.

    Thanks for all the help.

    Greg

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

Similar Threads

  1. Replies: 6
    Last Post: 12-03-2017, 02:23 PM
  2. Replies: 3
    Last Post: 12-29-2015, 04:06 PM
  3. Replies: 3
    Last Post: 05-30-2014, 12:34 AM
  4. Retreive Blank Form upon Record Entry
    By michael.legge@rbc.com in forum Access
    Replies: 2
    Last Post: 07-12-2013, 02:26 PM
  5. Replies: 3
    Last Post: 11-20-2012, 01:40 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