Page 2 of 2 FirstFirst 12
Results 16 to 28 of 28
  1. #16
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544

    Nope Bob we are are both wrong....
    Well at least you've got it right now
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  2. #17
    sheckay is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    73
    Hmmmm...same deal. It gives me the message no matter what number I enter. Do you think the issue is that the fields that are the set limits Me.DTPlus and Me.DTMinus are calculated fields? They are functioning, and displaying the correct value. But they are set to hold the result of the diameter plus the tolerance, and the other one is the diameter minus the tolerance.

  3. #18
    sheckay is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    73
    I've tried the field's validation rule too. > [DTMinus] And < [DTPlus] I also tried Or instead of And. I get error messages no matter what number I enter.

  4. #19
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Walk through the code and inspect the controls within the 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

  5. #20
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Why not use table validation?

    Table validation rule property:
    Code:
    ([lower_bound]<[upper_bound]) And ([my_number]>=[lower_bound]) And ([my_number]<=[upper_bound])
    Table validation text property:
    Code:
    x has to be between y and z. Try again.
    Click image for larger version. 

Name:	Untitled.png 
Views:	17 
Size:	20.9 KB 
ID:	47858

  6. #21
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Quote Originally Posted by sheckay View Post
    Hmmmm...same deal. It gives me the message no matter what number I enter. Do you think the issue is that the fields that are the set limits Me.DTPlus and Me.DTMinus are calculated fields? They are functioning, and displaying the correct value. But they are set to hold the result of the diameter plus the tolerance, and the other one is the diameter minus the tolerance.
    In light of this I made some adjustments to my previous suggestion

    Click image for larger version. 

Name:	Untitled.png 
Views:	18 
Size:	30.1 KB 
ID:	47859

  7. #22
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Quote Originally Posted by sheckay View Post
    Hello Micron. Text94 is just the name of the text box used to enter a number.
    I said 94, as in the value 94 - not Text94.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #23
    sheckay is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    73
    Hmmm, I'll try that. I had read that to reference other fields, I'd have to use the field's validation rule. But I'll try the form's.

  9. #24
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Quote Originally Posted by sheckay View Post
    Hmmm, I'll try that. I had read that to reference other fields, I'd have to use the field's validation rule. But I'll try the form's.
    If this is directed at me note that I was talking about the *TABLE* validation properties. The table would validate itself no matter what form you used to input the data.

    Side note: this should be a really straight forward task, either at table or form level. If you're still having problems at this point I suggest posting a copy of your db for review.

    Another side note: you mentioned 'calculated fields'. Actual calculated fields within a table are baaad juju. But given the context of this thread I'm guessing they're calculated *controls*? Another reason it might be a good idea to post your db for review.

  10. #25
    sheckay is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    73
    Sorry. I must have misunderstood.

  11. #26
    keviny04 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Apr 2015
    Posts
    128
    I'm surprised this hasn't been solved yet after a week. And it's quite a simple problem. The comparison didn't work because it compared a STRING to a calculated value. To make it work, make sure all values are numeric. The calculated fields are numeric already. So you have to make sure the user entry is numeric too. Use the Val() function as follows:

    Code:
    Private Sub Text94_BeforeUpdate(Cancel As Integer)
        If Val(Me.Text94) < Me.DTMinus Then
        ' Display a message
               MsgBox "Your Entry is Outside of the Tolerance Range. Too low!!", vbExclamation
              ' Cancel the update
              Cancel = True
         End If
         If Val(Me.Text94) > Me.DTPlus Then
         ' Display a message
               MsgBox "Your Entry is Outside of the Tolerance Range. Too high!!", vbExclamation
               ' Cancel the update
              Cancel = True
         End If
    End Sub

  12. #27
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I asked for sample data back in post 7. No wonder a simple problem hasn't been solved 19 posts later.
    Val stops reading numbers as soon as a character isn't a number, so if data/range is like P456 Val is of no use. I looked for sample data/ranges before deciding to say that and didn't see where any was offered so I think it's premature to suggest Val or anything else.
    Last edited by Micron; 05-25-2022 at 02:56 PM. Reason: added comment
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #28
    keviny04 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Apr 2015
    Posts
    128
    Quote Originally Posted by Micron View Post
    I asked for sample data back in post 7. No wonder a simple problem hasn't been solved 19 posts later.
    Val stops reading numbers as soon as a character isn't a number, so if data/range is like P456 Val is of no use. I looked for sample data/ranges before deciding to say that and didn't see where any was offered so I think it's premature to suggest Val or anything else.
    Sometimes you need some sixth sense to solve problems like this. I didn't see any sample data either. I just tried all possibilities I could think of, as every troubleshooter should. Val() is just one way, and there are other ways. The crux of the matter is the user entry has to be converted to a numeric value in this case.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Prevent entry of duplicate Personal ID Number
    By jerryg72 in forum Access
    Replies: 8
    Last Post: 12-07-2021, 07:07 AM
  2. The Category ID number System
    By Lou_Reed in forum Access
    Replies: 2
    Last Post: 10-05-2015, 12:18 PM
  3. Replies: 5
    Last Post: 04-11-2015, 03:54 AM
  4. Replies: 3
    Last Post: 02-16-2015, 01:04 PM
  5. Replies: 22
    Last Post: 02-11-2013, 03:03 PM

Tags for this Thread

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