Solved

Opening individual record by clicking on Datagrid

Posted on 2003-11-02
7
322 Views
Last Modified: 2013-12-25
Using VS6 SP5, Ado , Win2K and Access 2K.

Have a datagrid returning records, wanted to double click on individual record
and it open in its own form for editing purposes. Vinnyd179 provided the code below which works great, however when I change a control's value and
close with Adodc1.Recordset.Update, it doesn't update the record. I assume
the code below only populates the controls and doesnot allow editing...
Can anyone explain to me how to make this form update the current record that is being displayed,( I assume that the record isn't actually opened and that the values that have changed actually need to be inserted back into the Access DB, But I just don't know how to open that exact individual record and append the updates.....

use the double click event of the grid:

' assumes rs is a public recordset

Private Sub DataGrid1_DblClick()
Load Form2
' clear boxes
Form2.Text1 = ""
Form2.Text2 = ""
Form2.Text3 = ""
' populate Textboxes from rs recordset
With rs
    Form2.Text1 = .Fields("Field1").Value
    Form2.Text2 = .Fields("Field2").Value
    Form2.Text3 = .Fields("Field3").Value
End With

Form2.Show

End Sub


Just3082
0
Comment
Question by:just3082
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9667336
Have you tried using the adodc instead of a recordset in the above?

' populate Textboxes
With Adodc1
    Form2.Text1 = .RecordSet.Fields("Field1").Value
    Form2.Text2 = .RecordSet.Fields("Field2").Value
    Form2.Text3 = .RecordSet.Fields("Field3").Value
End With
0
 

Author Comment

by:just3082
ID: 9667448
Yes, This is what I have: However  form2(Assigned_Tickets) opens
and displays the info fine, I can't change any of the data. I can, but it doesn't
send it back to the DB. I've got the controls on the form bound to Adodc1, So
I can't figure out why it isn't working.... Look below the first code for the code in the second form.

Private Sub DataGrid1_DblClick()
Load Assigned_Tickets
Assigned_Tickets.Text1 = Adodc1.Recordset.Fields("Issue").Value & ""
Assigned_Tickets.Text2 = Adodc1.Recordset.Fields("Resolution").Value & ""
Assigned_Tickets.Text3 = Adodc1.Recordset.Fields("Requestor").Value & ""
Assigned_Tickets.Text4 = Adodc1.Recordset.Fields("Time").Value & ""
Assigned_Tickets.Text5 = Adodc1.Recordset.Fields("TicketID").Value & ""
Assigned_Tickets.Text6 = Adodc1.Recordset.Fields("CallTakenBy").Value & ""
Assigned_Tickets.Text7 = Adodc1.Recordset.Fields("Date").Value & ""
Assigned_Tickets.Text8 = Adodc1.Recordset.Fields("ResponseToRequestor").Value & ""
Assigned_Tickets.Text9 = Adodc1.Recordset.Fields("NotesToTech").Value & ""
Assigned_Tickets.Text10 = Adodc1.Recordset.Fields("Extension").Value & ""
Assigned_Tickets.Text11 = Adodc1.Recordset.Fields("Location").Value & ""
Assigned_Tickets.Combo1 = Adodc1.Recordset.Fields("Status").Value & ""
Assigned_Tickets.Combo2 = Adodc1.Recordset.Fields("AssignedTo").Value & ""
Assigned_Tickets.Combo3 = Adodc1.Recordset.Fields("Category").Value & ""
Assigned_Tickets.Combo4 = Adodc1.Recordset.Fields("Escalate").Value & ""
Assigned_Tickets.Combo5 = Adodc1.Recordset.Fields("Department").Value & ""
Assigned_Tickets.Text12 = Adodc1.Recordset.Fields("ComputerName").Value & ""
Assigned_Tickets.Text14 = Adodc1.Recordset.Fields("UserName").Value & ""
Assigned_Tickets.Show
Unload JMHTickets
End Sub


Private Sub Update_Click()
Adodc1.Recordset.Update
Unload Me
JMHTickets.Show
End Sub

Just3082
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 125 total points
ID: 9667487
>>  I've got the controls on the form bound to Adodc1

If they are bound,then wouldn't they be populated without the need for setting the Text to the record values like this:

Assigned_Tickets.Text1 = Adodc1.Recordset.Fields("Issue").Value & ""

Are you binding the Textboxes on Form2 to the ado control on form1?




0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:just3082
ID: 9667618
Ok, Everything is working fine now. Apparently all I needed to know to begin with was how to change the record selection in the grid to Row.
This is why before when I click on it, it would open form2, but display
the first record in the DB instead of the record I thought I was clicking on, When in actuality I was clicking on a field, because I didn't have the Row selection enabled. Yes, I feel pretty dumb.....

Thanks Vinnyd179 ....

Just3082
0
 

Author Comment

by:just3082
ID: 9671232
No, I was wrong. When I double click on a record it opens my form2, however it displays
the first record in the set instead of the actual record I double clicked on in the datagrid from form1...

Just3082
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9674999
How are the controls on Form2 bound to the ADO Control?Which Form is the ADO control on?


0
 

Author Comment

by:just3082
ID: 9680888
The first form is a simple datagrid with adodc1 to my Ticket database
the second form is full of controls, ADODC1 also to my tickets database, However I have
the adodc1 control disabled on form2 and hidden. I only want the record I clicked on to
be displayed. To answer your question: the controls on form2 are bound through VS6.
I've selected each control and chose adodc1 and the corresponding value in the datafield.

Just3082
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question