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

How to set variable to induvidual row?

Okayy, basically i'm designing a program atm for my college coursework, and have been trying to get a search button to work. Basically, I need a way so that after the customer id has been found, my variable (in this case inc) needs to set itself to the row which the customer id that has been found is in. the idea is that it finds the row, and fills in the textboxes which i have with the data Here's the bit of code i have atm:

(And btw, inc is set as an integer earlier on in the program)

Expand|Select|Wrap|Line Numbers
  1. Dim CustomerID As Integer
  2. 'asks for the customer's ID number so that their results can be found.
  3. CustomerID = Val(InputBox("what is the Customer number?"))
  4.  
  5.  
  6. Try
  7. Sql = "Select * from tblQuotes WHERE CustomerID = " & CustomerID
  8.  
  9. 'dataAdapter obtains data from database
  10. da = New OleDbDataAdapter(Sql, con)
  11.  
  12. da.Fill(ds, "CustomerID")
  13. 'count number of rows(records) in the dataset
  14. 'finds the row which the customer id is in
  15. inc =WHATEVER THE ROW NUMBER IS
  16. If ds.Tables("CustomerID").Rows.Count > 0 Then
  17. TxtName.Text = ds.Tables("TblQuotes").Rows(inc).Item("CustomerName")
  18. TxtHouse.Text = ds.Tables("TblQuotes").Rows(inc).Item("HouseNumberName")
  19. TxtTown.Text = ds.Tables("TblQuotes").Rows(inc).Item("TownCity")
  20.  
etc...

hopefully with the text WHATEVER THE ROW NUMBER IS being replaced by actual code to get it to that row.

Also, if this is not possible, can anyone suggest a better way of doing it?

Thanks in advance for any help
Feb 16 '11 #1
1 1434
MrMancunian
569 Expert 512MB
You can use a For...Next loop to loop through your dataset and check every row if the ID matches your value. If so, set your variable inc to that rownumber and you're done.

Steven
Feb 21 '11 #2

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

Similar topics

1
by: Scott | last post by:
I have an XML Document in a format like: <Variable name="Bob">ABCDEFG</Variable> <Variable name="Steve">QWERTYUI</Variable> <Variable name="John">POIUYTR</Variable> <Variable...
4
by: Frederik Sørensen | last post by:
I include a xslt stylesheet with variables for all the error messages in my system. <xsl:variable name="Banner_error_1"> errormessage 1 for banner </xsl:variable> <xsl:variable...
134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
10
by: Blaxer | last post by:
There is probably a really easy way to do this, so please forgive me but I would like to set the value of a variable from a variable, an example would be... function Calculate_Something(ByVal...
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
3
by: rls03 | last post by:
I have the following which creates a variable containing a relative path where <xsl:value-of select="."/returns a portion of the filename: <xsl:variable...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
2
by: Florian Loitsch | last post by:
hi, What should be the output of the following code-snippet? === var x = "global"; function f() { var x = 0; eval("function x() { return false; }"); delete x; alert(x); }
37
by: minkoo.seo | last post by:
Hi. I've got a question on the differences and how to define static and class variables. AFAIK, class methods are the ones which receives the class itself as an argument, while static methods...
112
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...

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.