VB.net and Access Help

I am new to VB.net programming and have to design a windows application through vb.net connected to a database.

I have managed to get the connection between vb.net and access working fine but am just having trouble doing the other functions.

What I want to do is to be able to select numbers (id numbers) through a drop down list or combo box through my form.  When I select a number it will then bring up the record of that person.  The records that I need to select are simply the persons name and their email address.

Is it possible to do this, I have tried a lot of things and have been unsucessful so far.

Is there anybody out there that could provide an actual working example or give me guidance on what I should do to get this working ok.  I am a complete beginner and finding this hard to get completed.

Many Thanks.
perti83Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Arthur_WoodCommented:
yes, what you want to do should be quite easy to accomplish.

can you show some of the code that you have tried so far, so we can gague where you are coming from?

AW
0
perti83Author Commented:
What I have done so far has no relevance to what I am actually trying to do.

I was using a tutorial which I was working through and then realised that it used a dataset to display the records which is no good to me at all.

What I need is a form that has the fields name and email populated when the associated id number is selected.  This is part of an email form, I am doing the interface section and then it has to be passed onto somebody else to get the further functionality working.

Basically what I have is no good whatsoever to get me going again, I cannot think of what else to do as I have went through so many books and tutorials on this I still cannot figure out how to do it.

Many Thanks.
0
RonaldBiemansCommented:
Hi Perti83,

Well if you have already got the connection and the dataadapter working then somethinh like this is all your need

    Dim ds As New DataSet
    Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        OleDbDataAdapter1.Fill(ds)
        cbID.DisplayMember = "ID"
        cbID.ValueMember = "ID"

        cbID.DataSource = ds.Tables(0)

        txtName.DataBindings.Add("text", ds.Tables(0), "PName")
        txtEmail.DataBindings.Add("text", ds.Tables(0), "Email")

    End Sub
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

perti83Author Commented:
Hi RonaldBiemans,

many thanks for your reply.

Is there any code that I need to go under the combo box that I am going to use to select the member id from which then in turn retrieves the member name and member email of the associated id that has been chosen.

Many Thanks Again.
0
abbdanCommented:
I used the datareader procedure below to accomplish the task of populating a drop box with column data from my SQL database.  You could do something similar to this with Access and pull in the column containing the ID numbers for each user record in your database.

  Private Sub GROUPSDropDownProcedure2()
        Dim DDL2Reader As System.Data.SqlClient.SqlDataReader
        GROUPSDropDownList2.Items.Clear()
        SqlAuthenticationConnection.Open()
        DDL2Reader = SqlGroupDropBoxcmd.ExecuteReader()
        Do While DDL2Reader.Read()
            Dim NewItem As New ListItem()
            NewItem.Text = DDL2Reader("Description")
            NewItem.Value = DDL2Reader("GROUP")
            GROUPSDropDownList2.Items.Add(NewItem)
        Loop
        DDL2Reader.Close()
        SqlAuthenticationConnection.Close()
    End Sub
0
RonaldBiemansCommented:
Hi perti83,

there is no extra code needed because the example I gave binds the textboxes to the same datasource as the combobox
which means if you select an id from the combobox the textboxes will automatically fill whit the correct name and email
0
perti83Author Commented:
Many Thanks For Your Comments

I will have a look at this to see if I can do anything with it, I am new to vb.net so might find it a struggle to do this.

Much Appreciated

Many Thanks Again.
0
RonaldBiemansCommented:
Hi Perti83, If you need any additional just ask :-)
0
perti83Author Commented:
Hi RonaldBiemans,

Many Thanks Again.

I understand exactly what you are trying to say, I am a bit rusty on understanding this all but am getting there.

I will try this now to see how far I can get.

Many Thanks Again.

Ciaran.
0
RonaldBiemansCommented:
Hmmm, I meant

Hi Perti83, If you need any additional help, just ask :-)
0
perti83Author Commented:
Sorry about that.  I was typing my replies to you when you were typing your replies to me, got a bit confusing :)

I didnt mean to say that I wasnt understanding you additional help offer I meant it was hard for me to understand the first thing that you said.  

Thanks Again.
0
perti83Author Commented:
Hi RonaldBiemans,

I tried using your code last night but did not succeed at all.

I have got it working up to a certain point where I can actually put a load button in to call the contents of the table that I have assigned through the DataSet.  I have got the three data items binded okay that I need and when I click on the Load button it brings these up for me ok.

What I am looking to do is for the data to be automatically loaded and then I can select the number that I want.

I am totally baffled my this.

Is there any possibilty you could have a look at this if I emailed it to you, I have it fully working up to the above point and that is it.  If not that is no problem.

Many Thanks Again.
0
RonaldBiemansCommented:
No that is no problem, But it is a rule here at EE that you should post your code here. so if you just copy and paste the code you have here. if this is a problem you can send it to ronald at compagnie dot be
0
RonaldBiemansCommented:
sorry that is  ronald dot biemans at compagnie dot be
0
perti83Author Commented:
Hi RonaldBiemans,

Many thanks for getting back me so quickly.  The reason I wanted to email it is so as the dataset is restored etc and the link to the database etc so that it will be easier for you to understand as you already have helped me out a lot.

When I get this working I will post my fully working code up here so that it will give others an idea how to do it.

Many Thanks Again.
0
RonaldBiemansCommented:
Ok send it to me then
0
perti83Author Commented:
Did you get it okay.

I sent it 5 minutes ago
0
RonaldBiemansCommented:
haven't got it yet, is it big
0
perti83Author Commented:
It is not big,

I have the files on a server that you can access and sent you the link via email.

I will try another email address to see if that works.

Many Thanks Again.
0
RonaldBiemansCommented:
Nothing yet, it is ronald dot biemans at compagnie dot be
0
perti83Author Commented:
I have sent it again from another email account and I have received it okay as I copied it to myself.  Might just be slow getting to yuor web server

Thanks.
0
RonaldBiemansCommented:
Hi Perti83,

This is it.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            OleDbDataAdapter2.Fill(DsStudentEmail1)

            cboStudentNumber.DisplayMember = "Student ID"
            cboStudentNumber.ValueMember = "Student ID"
            cboStudentNumber.DataSource = DsStudentEmail1.stud_details

            txtStudentName.DataBindings.Add("Text", DsStudentEmail1.stud_details, "Student Name")
            txtStudentEmail.DataBindings.Add("Text", DsStudentEmail1.stud_details, "Student Email")
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

    End Sub

some explanation:

you have to remove the databindings you have added in design time,
you can remove the load button and the code associated with it. Then paste the above code in your form code.


if you need an explanation of the above code, just ask :-)

Ronald

PS. some additional help.

try not to use spaces in your field names in the db, sometimes this can cause problems or atleast more work
only use strongly typed datasets once you are sure the the layout of the table won't change (or only a little)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
perti83Author Commented:
Hi RonaldBiemans,

many thanks for this solution.

What do you mean by removing the data bindings in design time, does this mean I have to remove all data bindings, and if I remove them do I not have to put them back in, in order for this to work properly.

Many Thanks Again.
0
RonaldBiemansCommented:
Hi Perti83,

just remove the databindings for the 2 textboxes (txtStudentName,txtStudentEmail) and the combobox(cboStudentNumber), and you don't have to add them again, because my code does that.
0
RonaldBiemansCommented:
Hi Perti83,

Could you close this question.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.