473,396 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VB in MS Access - Using < and > ...Please help

agroover
I know the following code is probably way off, but I really need some help with this. I keep trying different things, but nothing seems to work. I'm just getting really frustrated. Below is what I have so far.

If Grade.text = 1006, then I don't want the user to be able to put certain values into the C textbox. The value needs to be >= 0.04 and <= 0.06. If they enter any other value, I want a message box to appear saying that the value is not valid.

Expand|Select|Wrap|Line Numbers
  1. Private Sub C_Enter()
  2.  
  3. GRADE.SetFocus
  4. C.Locked = False
  5.  
  6. If Trim(GRADE.Text) = "1006" Then
  7.     ElseIf C.Value >= 0.04 Then
  8.         MsgBox "Value must be between 0.04 and 0.06"
  9.     ElseIf C.Value <= 0.06 Then
  10.         MsgBox "Value must be between 0.04 and 0.06"
  11.     Else
  12.  
  13. End If
Any help at all would be greatly appreciated. I've searched everywhere trying to find out what I need to do and what is wrong. I'm not sure if I should use the DMin and DMax functions or not.

I'd really appreciate any sugguestions someone might have.

Thanks
Apr 4 '07 #1
6 1740
Tig201
103 100+
Try
code
Expand|Select|Wrap|Line Numbers
  1. If Val(C.Text) >= 0.4 And Val(C.Text) <= 0.6 Then
  2. MsgBox ("enter a value between 0.4 and 0.6")
you may also want to add error checking to validate C.Text isnumeric
Apr 4 '07 #2
Killer42
8,435 Expert 8TB
Actually agroover, your code looks as though it's very close to doing what you want. You've just got the syntax of your nested IF statements a little jumbled.

Try this slight modification...

Expand|Select|Wrap|Line Numbers
  1. Private Sub C_Enter()
  2.  
  3. GRADE.SetFocus
  4. C.Locked = False
  5.  
  6. If Trim(GRADE.Text) = "1006" Then
  7.     If C.Value >= 0.04 Then
  8.         MsgBox "Value must be between 0.04 and 0.06"
  9.     ElseIf C.Value <= 0.06 Then
  10.         MsgBox "Value must be between 0.04 and 0.06"
  11.     End If
  12. End If
Oh, and you probably should just use "<" and ">" rather than ">=" and "<=". After all, if you are telling the user the value must be 0.04 to 0.06, it seems a bit unfriendly to complain when they enter 0.04 or 0.06, doesn't it.
Apr 5 '07 #3
Thank you both for your help. I'm going to try it out and let you know if they work out. Thanks again for the suggestions and the help. It's greatly appreciated.
Apr 5 '07 #4
Killer42
8,435 Expert 8TB
Thank you both for your help. I'm going to try it out and let you know if they work out. Thanks again for the suggestions and the help. It's greatly appreciated.
I just realised, we had our "less than" and "greater than" backwards. You'll need to swap them around.
Apr 6 '07 #5
Thank you Killer42 andTig201 for all of your help. I was able to get the code to work.

Below is the code I ended up using.

Expand|Select|Wrap|Line Numbers
  1. Private Sub C_LostFocus()
  2. GRADE.SetFocus
  3. C.Locked = False
  4.  
  5. If Trim(GRADE.Text) = "1006" Then
  6.     If C.Value < 0.04 Or C.Value > 0.06 Then
  7.         MsgBox "Value must be between 0.04 and 0.06"
  8.     End If
  9. End If
  10.  
  11. End Sub
Thanks again.
Apr 9 '07 #6
Killer42
8,435 Expert 8TB
Excellent! Glad we could help. :)
Apr 9 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
8
by: Daniel Hansen | last post by:
I know this must seem totally basic and stupid, but I cannot find any reference that describes how to control the spacing between <p>...</p> and <div>...</div> blocks. When I implement these on a...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
0
by: hapordigi | last post by:
while i was using the sample code of MS Soap Toolkit 3.0 to access a web service created by c#, an error was returned like: // cout<<(const char*)Reader->RpcResult->text<<endl soap:client i...
0
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
5
by: Nathan Sokalski | last post by:
My Web.config file contains the following section to register some of my UserControls: <pages> <controls> <add tagPrefix="NATE" tagName="Banner" src="~/Banner.ascx"/> <add tagPrefix="NATE"...
4
by: Debbiedo | last post by:
My software program outputs an XML Driving Directions file that I need to input into an Access table (although if need be I can import a dbf or xls) so that I can relate one of the fields...
1
by: shalini jain | last post by:
Hi, I want to know how can we do pagination using XSL. There are number of tutorials available on pagination using PHP but nothing with XSL. i am really stuck with my code. Below is the code that...
1
by: Webstorm | last post by:
Hi, I hope someone can help me sort this out a bit, Im completely lost. Here is the page I am working on: http://www.knzbusinessbrokers.com/default.asp I have 3 search critera that I need to...
1
by: Brit | last post by:
I have an ASP file that retrieves names from an Access database for 4 different categories of membership, which the visitor to the page selects (corporate, institutional, regular, or student). The...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.