Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid1_click event procedure

Status
Not open for further replies.

SteveMCSE

Programmer
Nov 12, 2002
78
US
Ok, here is the deal. I have a datagrid that is bound to a customer file. when the user clicks on any field in a record, it should open a new form with that customer's information in it. it does open the form, it does have information in it, but the problem is this:
let's say there are just two records for simplicity.
record customer number 1
and
record customer number 2
when the user clicks on customer 2 it opens the form with customer 1's info. then, the user closes the form, and clicks on customer 2 again and it opens with customer 2's info. when the user clicks customer 1, it opens with customer 2's info and then when the user clicks customer 1 again, it then opens with customer 1's info. it is basically acting like the record that is clicked is selected AFTER the form is opened. I want to know how i can change that order. I need it to select that record in teh datagrid control BEFORE the form is opened so that it will open the form with the correct record the first time. not the second like it is doing. please, any help would be wonderful. I have looked just about everywhere i can think. Thank you. Steve Harper
 

This is because the click event happens before the cursor is actually repositioned to the next record.

Instead of the click event, use one of the following:

1. DoubleClick event
2. Button click
(with the above two suggestions, the user has to click on the row, and then click the button of perform a double click)

3. RowColChange event. (you may need to use a form level boolean variable to prevent the action being taken during the loading of data, as this event may at that get invoked several times. And also use a check to invoke the form update only if the LastRow <> the current row.

4. Use the recordset's MoveComplete event. (Best).
You will need to declare your recordset object using the WithEvents keyword in the form's declaration section, or use an Adodc. [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top