By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,835 Members | 1,488 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,835 IT Pros & Developers. It's quick & easy.

Easy database question

P: n/a
What up,

All I need to do is enter a last name in a text box, query a MSAccess
database and display the name with the corresponding columns. This is
no problem, but when there are more than one records with the same
last name, I need to click a command button to display the next record
with that name. I cant find it in any of my books and it sounds like
an easy enough question. Any help is definately appreciated.

TIA,

LedZep
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
For easy questoin easy answer..:o))

I don't know what is exactly your current code but...I suppose that you are
using datasets
so, you can defiine a variable in the form class (so it will be global for
the form)

- after selecting for a new name set the variable to 1

- in the button
if myVariable < mydataset.tables("tablename").rows.count then
myVariable +=1
display mydataset.tables("tablename").rows (myvariable)
else
msgbox ("last one")
end if


"LedZep" <wa*********@hotmail.com> wrote in message
news:30*************************@posting.google.co m...
What up,

All I need to do is enter a last name in a text box, query a MSAccess
database and display the name with the corresponding columns. This is
no problem, but when there are more than one records with the same
last name, I need to click a command button to display the next record
with that name. I cant find it in any of my books and it sounds like
an easy enough question. Any help is definately appreciated.

TIA,

LedZep

Nov 20 '05 #2

P: n/a
wa*********@hotmail.com (LedZep) wrote in message news:<30*************************@posting.google.c om>...
What up,

All I need to do is enter a last name in a text box, query a MSAccess
database and display the name with the corresponding columns. This is
no problem, but when there are more than one records with the same
last name, I need to click a command button to display the next record
with that name. I cant find it in any of my books and it sounds like
an easy enough question. Any help is definately appreciated.

TIA,

LedZep


I forgot to mention I'm using vb.Net
Nov 20 '05 #3

P: n/a
Cor
Hi Led,
This depends really how you fill the textbox with the names.
You can use a reader or a dataset or a dataview etc.
Can you send a piece of code, maybe someone can help you then.
-reading the access file
-filling the textbox
Cor
Nov 20 '05 #4

P: n/a
"Cor" <no*@non.com> wrote in message news:<3f***********************@reader20.wxs.nl>.. .
Hi Led,
This depends really how you fill the textbox with the names.
You can use a reader or a dataset or a dataview etc.
Can you send a piece of code, maybe someone can help you then.
-reading the access file
-filling the textbox
Cor


If txtLast.Text <> "" Then
AddressBookDataSet.Clear()
AddressBookDataAdapter.SelectCommand.CommandText = _
"SELECT * FROM addresses WHERE lastname = '" & txtLast.Text
& "' "

AddressBookDataAdapter.Fill(AddressBookDataSet)

Display(AddressBookDataSet)
txtStatus.Text &= vbCrLf & "Query Successful " & _
vbCrLf

Else
txtLast.Text = "Enter last name here then press Find"
End If
When there's two records with the same last name I have to click a
command button to display the next record in the txtLast. Im lost.

Thanks,

LedZep
Nov 20 '05 #5

P: n/a
Cor
Hi Led.

Your dataset contains a simple table, I think you can reach it with (in a
kind of pseudo code)
\\\\\
dim i as integer
dim adress as string
adress = Addressbookdataset.table(0).rows(i)("adres").tostr ing
/////
You can to do a for each loop with
\\\
dim dr as datarow
for each dr in addressbookdataset.table(0).rows
adress = dr("adres").tostring
next
///
I hope this helps a little bit?
Cor

If txtLast.Text <> "" Then
AddressBookDataSet.Clear()
AddressBookDataAdapter.SelectCommand.CommandText = _
"SELECT * FROM addresses WHERE lastname = '" & txtLast.Text
& "' "

AddressBookDataAdapter.Fill(AddressBookDataSet)

Display(AddressBookDataSet)
txtStatus.Text &= vbCrLf & "Query Successful " & _
vbCrLf

Else
txtLast.Text = "Enter last name here then press Find"
End If

Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.