|
-
Aug 25th, 2004, 05:20 PM
#1
Thread Starter
Addicted Member
pass ID from 1 form to another
I have a datagrid, when the user clicks on a row, I want to direct the user to another form that displays the data selected as a single record..
How do I retrieve the ID field from the row selected in the datagrid..so that I can get all the tables that relate to that ID number on the new form??
THANK YOU
-
Aug 25th, 2004, 05:25 PM
#2
Lively Member
Do you have a key in the data or are you going to use the actual row ID as your key. You may want to have the key in your data and then hide that field so the user does not see it. Then you can key off that field.
-
Aug 25th, 2004, 05:28 PM
#3
Thread Starter
Addicted Member
the record has a primary key i.e. the customerID....
isn't there some way of recording the customerID of the record selected and using that in the next form in a query to retrieve the required tables????
-
Aug 25th, 2004, 05:43 PM
#4
Lively Member
you would use code something like this.
me.DataGrid1.Text
this will retrieve the text value of the row and column you selected. However, if there are several columns in your data you will need to specify which col you are looking for. It has been a while since I did this but if your key is in the 3rd column over you would first set the column like:
me.datagrid.col = 2 (I believe that datagrid columns start at 0)
Then you would do
me.datagrid1.text which would give you your value.
-
Aug 25th, 2004, 05:48 PM
#5
Thread Starter
Addicted Member
yeah k...fink i get what ur sayin...but i need to call that value on another form...how do I do that????
-
Aug 25th, 2004, 05:54 PM
#6
Lively Member
There are several ways to do this but here is one way.
Lets say you have two forms. Form1 has the datagrid and form2 is the form you want to use once you get the value from your datagrid.
Private Sub DataGrid1_Click()
form2.Show
form2.TextBox = Form1.DataGrid1.Text
End Sub
Now you have form2 open and you have the value. I don't know exactly what you want to do on form2 so I hope this helps
-
Aug 25th, 2004, 05:56 PM
#7
Thread Starter
Addicted Member
thanks m8...il have a go and then let you no
-
Aug 25th, 2004, 05:57 PM
#8
Lively Member
You could also create a vaiable in Form2
Public sVal as string
then when the user clicks the datagrid on Form1:
Private Sub DataGrid1_Click()
form2.Show
form2.sVal = Form1.DataGrid1.Text
End Sub
Now you have the variable stored in sVal
-
Aug 25th, 2004, 06:58 PM
#9
Thread Starter
Addicted Member
next problem...im trying to retreive the data from the table in the database... I want it to be shown in text boxes.... so what I used is the properities at the side to create a DataSource and assign a datafield to each text box.....
the problem is I don't no where to put the sql query...just now it returns the data of the first record....not of the selected row. (I've been able to send the value to the next page)....I just don't know where to put the query!!! can you help???
-
Aug 25th, 2004, 07:05 PM
#10
you may want to make this a new thread so people don't confuse it with the duplicates that you posted.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|