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?
11 2017
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)
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
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?
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)
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'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
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. -
Sub Greeting()
-
Dim strInput As String, strMsg As String
-
-
strMsg = "Enter your name."
-
strInput = InputBox(Prompt:=strMsg, _
-
Title:="User Info", XPos:=2000, YPos:=2000)
-
MsgBox "Hello, " & strInput
-
End Sub
-
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.
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: -
Dim x As Integer
-
Dim y As Integer
-
-
strFirstvalue = InputBox("Enter Starting Value", "Starting Value", x = 0)
-
strSecondvalue = InputBox("Enter Ending Value", "Ending Value", y= 100)
-
-
-
DoCmd.OpenReport "MTBF", acViewPreview, , "[Serial Number] Between " & x & " and " & y, acWindowNormal, " "
-
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
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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. ...
|
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;
|
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...
|
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...
|
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
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |