|
-
May 27th, 2005, 11:32 PM
#1
Thread Starter
New Member
Select from a Listbox or MSHFlexGrid
Hi Team
First let me say that I am so glad I found this forum. I have just spent the past hour browsing around. Very well done and very well supported.
Visual Basic: Version 6
Database: Access 97 format
Connection: Adodc / Jet
Problem.
I am very new to VB6. Two weeks to be exact. I have created an access database. I can show either a single item, "Name" in a Listbox or several selected fields in an MSHFlexGrid.
Is there a way to open the database record, to edit just the chosen record. So if I double click on a record half way down either the list box or MSHFlexGrid, it will open another form to edit that one record.
Cheers
Jim
-
May 28th, 2005, 09:30 AM
#2
Addicted Member
Re: Select from a Listbox or MSHFlexGrid
hi bagpiper,
on the onclick event of the msHflexgrid get the selected row's primary id value. store the value in a global variable and load the form where u will retrieve the record based on the global variable. and fill the form for editing.
-- Kishore..
-
May 28th, 2005, 09:49 AM
#3
Re: Select from a Listbox or MSHFlexGrid
Welcome to the forum
I'm not sure a global variable would be required - or actually preferred.
The listbox or flexgrid item that is clicked is known to the control.
So referring to the .ROW/.COL item of the flexgrid or the .SELECTED item of the listbox in the little form that is going to edit it.
Make sure the form that does the edit is loaded MODAL - so that another row or item cannot be selected on the original form while the edit is being done.
-
May 28th, 2005, 10:49 AM
#4
Thread Starter
New Member
Re: Select from a Listbox or MSHFlexGrid
Thanks for the replies.
I have chosen to use the .row solution with the flexgrid. Now no matter what I click on I can get the record ID stored in column 0.
How do I use this to open just that record though in a form please?
I have a form I use to add new records and want to pull this same form but open at the correct record.
I understand the concept just don't know how to impliment it.
Many thanks team
Jim
Last edited by Bagpiper; May 28th, 2005 at 11:01 AM.
Reason: Correction
-
May 28th, 2005, 11:51 AM
#5
Re: Select from a Listbox or MSHFlexGrid
Hi Jim, welcome to VBForums!
I would recommend creating a public sub in the "add record" forum which accepts a parameter specifying the record to edit, and this can be called from the grid form. Eg:
VB Code:
'In the DoubleClick event of the grid:
frmEditRecord.ShowRecord MSFlexGrid1.TextMatrix(0, CLng(MSFlexGrid1.Row))
'In the form to edit records
Public Sub ShowRecord (lRecordID as Long) '(i guessed that the ID is numeric, you may need to change "Long" to "String", and remove the CLng above)
'find/select the record here (how you do this depends on your current methods)
Me.Show
End Sub
(change MSFlexGrid1 to the name of your grid control, and frmEditRecord to the name of the form)
-
May 28th, 2005, 01:55 PM
#6
Thread Starter
New Member
Re: Select from a Listbox or MSHFlexGrid
 Originally Posted by si_the_geek
'find/select the record here (how you do this depends on your current methods)
Hi Si
Alas that is the other bit of the problem. I just don't have the basics to achieve that part of the problem. I know that once I am shown how to do this last part I will be fine.
Please can you help
I am off to see about getting some books out of Comp USA on this stuff.
Thanks to everyone for my welcome too.
Cheers and happy coding
Jim
-
May 28th, 2005, 02:29 PM
#7
Re: Select from a Listbox or MSHFlexGrid
ok, there are several ways to work with databases, what you need to do depends on what methods you are using.
what method are you using to add the record?
It's best if post your code, or attach your form if you are using a data control.
-
May 29th, 2005, 01:31 AM
#8
Thread Starter
New Member
Re: Select from a Listbox or MSHFlexGrid
Hi Si
Well, I went to the shops and found most of the books on Visual Basic are between $29.00 - $49.00. - I came home empty handed.
I need to go over the books I have me thinks.
I don't understand the questions that everyone is asking. I think I need to sit down and do a bit more reading first.
Thanks to everyone who has tried to help but I really am at beginner level.
I am enjoying this learning experience.
Will be in touch soon team
Cheers and happy coding
Jim
-
May 29th, 2005, 10:15 AM
#9
Re: Select from a Listbox or MSHFlexGrid
Thats fair enough, feel free to come back and ask questions any time you like.
We have lots of people on this site who are very knowledgable and happy to explain things to you, and most of us don't mind "silly" questions or re-explaining things either - we've all been beginners at some point and realise how confusing all the terminology can be.
-
May 31st, 2005, 12:50 PM
#10
Thread Starter
New Member
Re: Select from a Listbox or MSHFlexGrid
Hi Team
I just wanted to give you an update. I realise now that I needed to unbind the ADODC controls and learn a wee bit of SQL.
I do not have this issue resolved but I am heading in the right direction. I have just learned how to sort the records by date, which was bugging me. Problem is that items bound to ADODC are easy to learn but, from my limited knowledge, seem to be very inflexible.
Anyway, the learning process continues.
Thanks again for your efforts in helping me out.
Last edited by Bagpiper; May 31st, 2005 at 01:02 PM.
Cheers and happy coding
Jim 
-
May 31st, 2005, 12:54 PM
#11
Re: Select from a Listbox or MSHFlexGrid
You are definitely headed in the right direction. Bound controls hide so much of what goes on in the DB that you do not get a strong knowledge of SQL from it. And as soon as you want to do something outside the scope of the control it gets even harder.
Good luck and keep posting back with questions
-
May 31st, 2005, 12:57 PM
#12
Re: Select from a Listbox or MSHFlexGrid
 Originally Posted by Bagpiper
Problem is that items bound to ADODC are easy to learn but, from my limited knowledge, seem to be very inflexible.
100 zillion per cent correct.
Have you looked at Beacon's database tut that is posted at the top of this forum section?
In addition to that, there are numerous articles and such on writing SQL that you can find on the web.
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
|