473,406 Members | 2,620 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,406 software developers and data experts.

Input Boxes not valid for Where Expressions?

I'm new to VB and attempting something (seemingly very very basic by normal standards) and I can not seem to get my Where expression to read values from my inputbox. This is what i have and i am recieving an error sayings "The Microsoft Jet Database engine does not recognize 'x' as a valid field name or expression"

Dim x As Integer
Dim y As Integer

strFirstvalue = InputBox("Enter Starting Value", "Starting Value", "0")
strSecondvalue = InputBox("Enter Ending Value", "Ending Value", "100")

x = strFirstvalue
y = strSecondvalue

DoCmd.OpenReport "MTBF", acViewPreview, , "[Serial Number] Between x and y", acWindowNormal, " "


any simple fixes?
Jun 26 '07 #1
11 2017
puppydogbuddy
1,923 Expert 1GB
I'm new to VB and attempting something (seemingly very very basic by normal standards) and I can not seem to get my Where expression to read values from my inputbox. This is what i have and i am recieving an error sayings "The Microsoft Jet Database engine does not recognize 'x' as a valid field name or expression"

Dim x As Integer
Dim y As Integer

strFirstvalue = InputBox("Enter Starting Value", "Starting Value", "0")
strSecondvalue = InputBox("Enter Ending Value", "Ending Value", "100")

x = strFirstvalue
y = strSecondvalue

DoCmd.OpenReport "MTBF", acViewPreview, , "[Serial Number] Between x and y", acWindowNormal, " "


any simple fixes?

Yes, use the Val function to convert x and y from string to numeric as shown:

x = Val(strFirstvalue)
y = Val(strSecondvalue)
Jun 26 '07 #2
I've tried all different ways of putting x as a val, using val of the string and all return the exact same error. I just attempted your idea of x = Val( etc.) and it again returned that x isn't a valid field or expression

I dont understand it because when i just enter values like 20 and 30 instead of x and y it comprehends and runs the where expression, how is x=Val any different than just a typed in constant number
Jun 26 '07 #3
puppydogbuddy
1,923 Expert 1GB
I've tried all different ways of putting x as a val, using val of the string and all return the exact same error. I just attempted your idea of x = Val( etc.) and it again returned that x isn't a valid field or expression
Check the return value from your input box. What does it show?
Jun 26 '07 #4
puppydogbuddy
1,923 Expert 1GB
Check the return value from your input box. What does it show?

Try it this way:

strFirstvalue = InputBox("Enter Starting Value")
strSecondvalue = InputBox("Enter Ending Value")

x = Val(strFirstvalue)
y = Val(strSecondvalue)
Jun 26 '07 #5
I'm not entirely sure what you mean by that? I can use the x and y values in other expressions (i did that to make sure my input box was reading the values i type in).
Jun 26 '07 #6
I'm not entirely sure what you mean by that? I can use the x and y values in other expressions (i did that to make sure my input box was reading the values i type in).
EDIT: I tried your above post with shortening the inputbox code and same error occured
Jun 26 '07 #7
puppydogbuddy
1,923 Expert 1GB
I'm not entirely sure what you mean by that? I can use the x and y values in other expressions (i did that to make sure my input box was reading the values i type in).

I see what your problem is. You have the wrong syntax for the InputBox. Note syntax of line with x and y in the example.

From Access On-line Help:

InputBox Function Example

The following example uses the InputBox function to return the user's name. Note that you can't open a Help file from a dialog box created by the InputBox function in Microsoft Access.
Expand|Select|Wrap|Line Numbers
  1. Sub Greeting()
  2.     Dim strInput As String, strMsg As String
  3.  
  4.     strMsg = "Enter your name."
  5.     strInput = InputBox(Prompt:=strMsg, _
  6.         Title:="User Info", XPos:=2000, YPos:=2000)
  7.     MsgBox "Hello, " & strInput
  8. End Sub
  9.  
Jun 26 '07 #8
Ha ha...well thanks for the help, thought it was going to work but i still got the exact same error: Not accepting x or y as fields or expressions. I have a feeling it isnt in the code but rather access not wanting to read variables.
Jun 26 '07 #9
puppydogbuddy
1,923 Expert 1GB
Ha ha...well thanks for the help, thought it was going to work but i still got the exact same error: Not accepting x or y as fields or expressions. I have a feeling it isnt in the code but rather access not wanting to read variables.
No, it is your syntax. Try syntax below as is:
Expand|Select|Wrap|Line Numbers
  1. Dim x As Integer
  2. Dim y As Integer
  3.  
  4. strFirstvalue = InputBox("Enter Starting Value", "Starting Value", x = 0)
  5. strSecondvalue = InputBox("Enter Ending Value", "Ending Value", y= 100)
  6.  
  7.  
  8. DoCmd.OpenReport "MTBF", acViewPreview, , "[Serial Number] Between " & x & " and " & y, acWindowNormal, " "
  9.  
Jun 26 '07 #10
Thank you! My error's gone, i'm getting calculation errors but i can handle those i'm sure. Thanks for staying with me on that
Jun 26 '07 #11
puppydogbuddy
1,923 Expert 1GB
Thank you! My error's gone, i'm getting calculation errors but i can handle those i'm sure. Thanks for staying with me on that
No problem. Be sure and let me know if you need more help.
Jun 26 '07 #12

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

Similar topics

3
by: KathyB | last post by:
Hi, I'm trying to find a way to validate input text boxes where I don't know the names until the page is rendered. I've got 2 validate functions that fire with the onsubmit button of a "mini" form...
13
by: Eddie | last post by:
I need to validate a text input field. I just want to say if user enters 93101 or 93102 or 93103 or 93105 or 93106 or 93107 or 93108 or 93109 or 93110 or 93111 or 93116 or 93117 or 93118 or...
12
by: Susan Cranford | last post by:
Please forgive, I have looked at so much info I can't figure out how to put it together even though I know it must be fairly simple. I have an array of input text boxes (txtDOBn) where n is...
3
by: Fao, Sean | last post by:
Hello all, As stated in another message, it's been a long time since I've done any C coding and I'm not feeling comfortable that I'm doing this correctly. Basically, I'd like to verify that my...
2
by: charleswesley | last post by:
I find myself regularly needing to validate user input as either a) numeric only or b) valid email address format (user@domain.tld) I am assuming that there are regular expressions that can be...
2
by: jackson2005 | last post by:
OK, I need to do three different things. On the ONLOAD event I would like a popup box to open. In this popup box I need two text boxes. One for the UserName and one for the BillingTo name. ...
60
by: andrew queisser | last post by:
Is this code below valid C++? I'd like to use this construct but I'm not sure if it'll be portable. struct foo { char x; }; struct bar { char sameSizeAsFooX;
43
by: SLH | last post by:
hi people. im trying to validate input received via a text area on an ASP page before writing it to a database. i cant use client side javascript due to policy, so it all has to happen on the...
3
by: acecraig100 | last post by:
I am fairly new to Javascript. I have a form that users fill out to enter an animal to exhibit at a fair. Because we have no way of knowing, how many animals a user may enter, I created a table...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.