473,473 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Access is asking for multiple parameter value requests for the same variable

1 New Member
Hi everyone,

I'm not a VBA expert and this has me stumped.

I am defining an integer, I then use inputbox to get the user defined value.

When this runs, the user enters the value when prompted. Immediately after this the user asked to enter the parameter value for the same integer (shf).

Immediately after this, they are asked for exactly the same parameter value.

Immediately after this, it carries on and does the job.

Any ideas?

Here's the simple code:
Expand|Select|Wrap|Line Numbers
  1. Dim x As Integer
  2.  
  3. x = InputBox("Enter minimum shareholders funds in £'000's")
  4. If x < 100 Then
  5. MsgBox ("x is too low")
  6. GoTo 20
  7. End If
  8.  
  9. DoCmd.SetFilter WhereCondition:="[Operator]=[Forms]![user]![User]" & " AND [Status] = ""Data""" & " AND [Desc] Like ""*"" & [Forms]![user]![Keyword] & ""*""" & " AND [VarX] > X"
If it helps, I have seen that shf is then used twice in the same sub routine but why has it forgotten the value?
Nov 23 '17 #1
1 2214
NeoPa
32,556 Recognized Expert Moderator MVP
I can only guess that shf is a Field value in the Record Source of your Form or Report object. It doesn't appear anywhere I can see in your Filter string.

I'm not sure what you're trying to filter but a more recommended approach would be to set the Form or Report object's .Filter property directly. From code associated with the object you can use the format :
Expand|Select|Wrap|Line Numbers
  1. Dim strFilter As String
  2.  
  3. strFilter = "..."
  4. Me.Filter = strFilter
  5. Me.FilterOn = (Me.Filter > "")
Your use of X in the filter string is incorrect. The filter value is a SQL format command and as you have it would make it try to refer to a variable called X from the expression manager. As x, as you have it, is a VBA variable with scope limited to the procedure your code is found in, it won't have any idea how to reference it.

You need to pass the value of x into the string itself and get it to use that. Something like :
Expand|Select|Wrap|Line Numbers
  1. strFilter = Replace("([Operator]=[Forms]![user]![User]) AND " _
  2.                   & "([Status] = 'Data' AND " _
  3.                   & "([Desc] Like '*%K*') AND " _
  4.                   & "([VarX] > %X)" _
  5.                   , "%K", Forms("User").Keyword)
  6. strFilter = Replace(strFilter, "%X", x)
  7. Me.Filter = strFilter
  8. Me.FilterOn = (Me.Filter > "")
PS. You'll notice I didn't use the concatenator statement (&) to join multiple string literals together as you have. I use it only to allow a long line to be split across multiple lines. Doing it within a line gives no benefits apart from making your code more difficult to read.
Nov 27 '17 #2

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

Similar topics

3
by: lynn80 | last post by:
I am trying to set up a search function in Access 2003. Basically I have a table with 3 fields, Sample (e.g "01"), Site (e.g. "457"), and Base (e.g. "A") Sample Site Base 01 ...
13
by: cfrance1 | last post by:
Hello, I recently started working with access for a school project in my Information Systems Management class. I'm a Finance major so it's not like I had to get this deep into this stuff, but I...
1
by: waltnixon | last post by:
I've got an MS Access query which runs fine when double clicked and returns all of the rows in a test database I'm building. I've set up a multi group report based on the query. I immediately...
3
by: DhruviTrivedi | last post by:
Is there any way to get parameter value from variable like @Param1 varchar(50) @Param2 varchar(50) set Param1 ='value1' while --condition-- begin
3
by: myemail.an | last post by:
Hi all, I use Access 2007 and have come across this error a number of times. I have two tables (customer information) which should contain - ideally - the same data. I create a query to compare...
22
patjones
by: patjones | last post by:
Hi - I have a bound form with a bunch of text boxes connected to various fields. When someone types a search value into txtSearch and either tabs out or hits Enter, the following code runs...
0
by: Hansens | last post by:
Hi, I'm fairly new to using access and my VB skills are very limited. I built a form that had unbound text boxes that act as parameters in the queries that provide the form with field values....
3
by: Pam Starrett | last post by:
I am creating what I think should be an easy form, but I guess it isn't that easy for a beginner. I have a sum of impressions and a sum of clicks and need to create a column that gives the click thru...
3
by: Sandra Walsh | last post by:
I have a form called f_Dashboard which has the following code on the AfterUpdate() event of an unbound field called SelectCityAllTrips. This code opens a filtered set of records in f_MainTripForm...
7
by: time2hike | last post by:
The Problem: I have a report with one sub-report that give an Enter Parameter Value message on loading. The message appears when we open the report on a different computer than the development...
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
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.