?
Solved

Opening individual record by clicking on Datagrid

Posted on 2003-11-02
7
Medium Priority
?
324 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 500 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

765 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