473,597 Members | 2,157 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query Access Database and Display Data on New Form

4 New Member
I have a program in which I want to have the user enter two percentages and display the data matching the criteria on a new form. The query would be:
Expand|Select|Wrap|Line Numbers
  1. Select *
  2. From Corrosion
  3. Where corrpct1 >= {column in database} OR
  4.       corrpct2 >= {column in database}
  5.  
The way I currently have it written is to display only one row of data. I need to display any number of rows that meet this criteria. My current code is:

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnDetails_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDetails.Click
  2.         Dim form As New frmDetails()
  3.         Me.Hide()
  4.         form.Show()
  5.         Try
  6.             cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Corrosion.mdb;")
  7.  
  8.             cn.Open()
  9.             cmd = New OleDbCommand("select * from Corrosion", cn)
  10.             dr = cmd.ExecuteReader
  11.             While dr.Read()
  12.                 form.txtID.Text = dr(0)
  13.                 form.txtCountry.Text = dr(1)
  14.                 form.txtCompany.Text = dr(2)
  15.                 form.txtAsset.Text = dr(3)
  16.                 form.txtBlock.Text = dr(4)
  17.                 form.txtFacility.Text = dr(5)
  18.                 form.txtAreaItem.Text = dr(6)
  19.                 form.txtCode.Text = dr(7)
  20.             End While
  21.         Catch
  22.         End Try
  23.         dr.Close()
  24.         cn.Close()
  25.     End Sub
  26.  
This will open the new form and put the information in the textboxes I have. However, I never know how many textboxes I will need to display.

My questions are:

1. How can I do my query to incorporate the user entered criteria (in the where statement)?
2. How can I display ALL of the data instead of just one line?

Thank you for any help you can give.

Rhonda
Sep 6 '10 #1
1 2419
dip_developer
648 Recognized Expert Contributor
#1. your sql query will be like....
Select * From Corrosion Where {column in database} <=corrpct1 OR {column in database}<=corr pct2

#2. If this query returns more than one row then instead of using datareader use dataset....

fill the dataset(say ds) with this sql query

take a datagridview or listview or datalist in the frmDetails form

now put........
Dim form As New frmDetails()
Me.Hide()
form.DataGridvi ew1.DataSource= ds
form.Show()
Sep 8 '10 #2

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

Similar topics

0
1281
by: Doug Beacher | last post by:
I need to import data from a spreadsheet that is created new every day into an MS Access database. The data is in a workbook consisting of multiple work sheets. I plan to import using the TransferSpreadsheet method. The name of the spreadsheet will change every day, but the position of the data to be imported will always be the same. Here is my problem: Having never used this method before, I am unsure as to what to put in the...
1
40596
by: programmerKid | last post by:
Hi, I am trying to open mdb file to view tables in it but when I open mdb file it run form in it by itself, as a startup point. Can anyone please tell me how to view and change in tables and forms, where I am unable to open them. Thanks in anticipation. Kid.
12
20887
by: Wadim Grasza | last post by:
I want to store and display (on a form or a report) multiple pictures per record in an access database. The pictures are not stored within the database. They are stored as files and the database contains the paths to the pictures. The database consists of two tables: TABLE DATA ID Name LastName
5
3002
by: Bec | last post by:
I'm in desperate need of your help.. I need to build an access database and have NO idea how to do this.. Not even where to start.. It IS for school, and am not asking anyone to do my homework for me.. I am merely asking for help, perhaps pointers as to where to begin.. I've never used access before.. I'm rather cluey when it comes to
11
39087
by: saurabhbpl | last post by:
hi, i have a html drop down menus and i want to conver it into dynamically means that menu show data from database.how can i fetch data from database for using menus and sub menus using php and mysql.
2
1705
by: amitp | last post by:
I've an order placing application which generates reports(RTF) for a particular order deatils. My Vb applicaiton retrieves all the details for the particular order from the database and puts it in an access database in the form of tables. The table column names and the report field names are same. Each report has a particular table associated with it. My question is how can i populate the data from a table into a RTF report?
0
1961
by: asad56 | last post by:
I am workin with a superstore managment project. I connect Access database with main form . Then it work properly. But now I connect same database with another table or field in another form which is child of main form not working. Main form stil working but when try to open child a message show as Please select a valid SQL statement as "Select", "Delet" or "Updat" I am working with Access . I connect database in...
1
1447
by: evilash | last post by:
Hi, am creating a web form in visual studio to insert data into an access database. The web form text boxes on the aspx file are Textbox.Text, Textbox2.Text and Textbox4.Text. The info is going to an access database i have in my app_data folder called users.mdb. The field names are Username, Password, Email_Address. The textbox data is being sent in the same order to the fields and textbox order listed above. Am fairly new to visual studio...
6
2791
by: mandanarchi | last post by:
Before I begin I want to apologise if my explanations are less than clear; that said, I'll try and be as detailed as possible. Scenario: User (XP OS, running office 2003) - IP = 1xx.x.x.101 phone system (linux OS, running 'trixbox') - IP = 1xx.x.x.222 phones (aastra 55i IP phones) - IP = 1xx.x.x.201 I want to be able to click a button on the customer record on our database on their computer, and have that customers number sent to the...
14
11900
by: SunnyC | last post by:
I have a table as below in test.mdb Access database. on a form, I want to use lookup to capture the the last field name in a text on the form, in this case, it is 200906. by using some code I searched on the web site, I only can see all the field names, How can I just capture the last field name in the crosstab query. Thanks, SunnyC LocationNo Customer No Status 20090101 20090201 20090301 20090401 20090501 20090601 34 ...
0
7965
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7885
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8271
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8031
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
5847
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5426
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3923
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1493
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1231
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.