473,387 Members | 1,453 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,387 software developers and data experts.

Query with User Entered Criteria

My project consists of a user interface designed in Visual Studio 2010 Express. I have it linked to an Access database. At this time, I have two text boxes that the user will enter a number. I want to be able to write a query that will take the first and second number and pull the information from the database that is equal to or greater than the user entered number. I think the logic would be something like:

Expand|Select|Wrap|Line Numbers
  1.      If numOne => {user entered number here} or
  2.        If numTwo => {user entered 2nd number here} Then
  3.     {open new form with columns of data}
  4.  
Now, I am assuming I have to dim numOne and numTwo. Do these need to be the column names of the data in Access? Also, when I design a new form, how do I tell it to put the data from the database?

Thanks for any help you can provide.

Also, my data is in one table with about 20 columns. I want to pull data from 10 of those columns based on if it meets the user specified criteria.
Aug 17 '10 #1
3 1687
MrMancunian
569 Expert 512MB
Hi Rhonda,

To be able to get data from your Access database, you'll need to create a OleDB connection. I suggest you read the following articles that were provided by Bytes Experts:

How to use a database in your program Part I

How to use a database in your program Part II

How to create a database connection without using wizards

Good luck with that! If you have further questions, don't hesitate to come back!

Steven
Aug 19 '10 #2
Steven,

Thank you for your reply. I used the wizard to connect to my database.

If you don't mind, let me lay out what I am trying to accomplish and you can tell me if it is possible with VB.Net (using Visual Studio 2010 Express).

I have a database in MS Access with one table. I want to be able to query this database with multiple queries. At this time, I have a form set up with two text boxes. I want the user to be able to enter a number in each of these text boxes (as described above) and then select all of the information in the database (each row of information) where the percentages in either one of the two columns (or fields) (related to the text boxes) is => the user-entered number. I then want to display an additional form (like a report) with this information on it. I have the text boxes laid out on the additional form but need to know how to link those text boxes to the fields in the database.

I will be adding some drop-down boxes to use in other queries. Then I would compare the percentages and the information in the drop-down box to display the data. I don't see why this would not be possible in VB. If it is; how do I code the text box to link to that specific column in the database?

Thanks!
Aug 19 '10 #3
MrMancunian
569 Expert 512MB
I have the text boxes laid out on the additional form but need to know how to link those text boxes to the fields in the database.
You need to create an event that checks both textbox values. Most common is a button that fires an event, but you could also use the TextChanged event of the textbox. However, as you are going to query your database, I'd choose for the button or something that is fired when the user clicks it.

When you've checked the values of the textboxes, you store them in two separate variables. As you want them to be percentages, I'd choose for either Integer (rounded numbers), or Double (broken numbers). After that, you write a query, using the variables. It should something like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM [table] WHERE [column] BETWEEN [variable1] AND [variable2]
Now, try to figure out how to get the results of the query in a datatable and bind that table to your DropDownList.

I don't see why this would not be possible in VB.
Neither do I, everything is possible! :-)

Good luck! If you need help, don't hesitate to come back.

Steven
Aug 19 '10 #4

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

Similar topics

13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
0
by: MLH | last post by:
I have an A97 query (qryVehiclesNowners2) that has a table field in it named . Depending on the selections made in a number of criteria choices on a form, a field on the form will have string...
0
by: emer.kurbegovic | last post by:
I need to build a filter that will filter user entered html and which will allow only certain html tags through (i.e. <IMG>, <SCRIPTand <EMBEDwould be allowed). i was going to HtmlEncode the...
0
by: tenko | last post by:
here's a question regarding changing units, say from g to kg without changing the entire codes.... my mathematical equation uses KG (kilograms), but the user can choose whether to enter values in...
9
by: Anneybo | last post by:
Alright, I give up! I'm asking the experts. I have created a database that calculates PTO for employees. I need to be able to cache the report by user entered dates and specific employee names. I...
5
by: ilikebirds | last post by:
Is it possible to create a union query that contains criteria from another union query? I would like the query to only display the order numbers from TeamUnions that are either contained in...
49
by: martin DH | last post by:
Hello all, I'm back with another SQL related problem. The details are below, but in short: I am using Access 2003. I have a table whose structure may include four different associate names per...
0
by: dgs | last post by:
How to scan the user-entered value ? like, we have "scanf()" in 'C'.......
4
by: ghjk | last post by:
I want to compare user entered date with data base datetime value. Database value in datetime type and first i want to extract date part and then compare with user entered value. This is my query....
2
by: gilly1471 | last post by:
Yep, new to perl, I started yesterday, but am quickly excelling. I would just like to know how to use user entered data. Let's say I have a programm that calculates the circumference of a circle....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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,...

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.