?
Solved

MSFLEXGRID control setting focus to wrong field

Posted on 2008-11-12
8
Medium Priority
?
768 Views
Last Modified: 2013-12-26
I have an MSFLEXGRID control on a form. I am loading it from a recordset and when I click on a row, I have that row of items (plus quite a few more fields related to that item) load into textboxes on the form. All of this works beautifully. I give the user the ability to update the textboxes and it will refresh the grid... all is good.

My problem is whenever the grid loses focus and then I click on a row in the grid it selects the 1st field of the 1st column. The next click works fine. It's only when the grid is getting focus back that it always selects the same field... no matter where I click. How can I get the grid to select the proper row (or cell) when I click on it when the grid is getting focus?
0
Comment
Question by:md0333
  • 3
  • 3
6 Comments
 
LVL 13

Expert Comment

by:game-master
ID: 22946150

good morning!

can i see ur code on the click event of the flexgrid.
do you also have code on the gotfocus?


game-master
0
 

Author Comment

by:md0333
ID: 22946416
I call another sub from the Click event.... but the problem comes immediately. I have the grid SelectionMode as FlexSelectionByRow.  Anytime I click on a Row it gives me the value for the 1st field (Which is a Deal Number) in the row.

Private Sub MSFlexGrid1_Click()
     giDealNum = MSFlexGrid1.Text   'Set Deal Number Variable
     getGridInfo MSFlexGrid1.Text     'Send Deal Number and Load Customer info screen
End Sub

I use that deal number to build my select statement and load all of the textboxes on the screen.  Problem is if the Grid does not have focus and I select a row in the grid it will always bring back the Deal Number from the 1st row. It doesn't make a difference if I put the code in the click event or in the gotfocus event... still comes back as row 1.

I've tried changing the SelectionMode to flexSelectionFree but that doesn't help either...


0
 
LVL 13

Expert Comment

by:game-master
ID: 22947281


good afternoon.
try this approach...


Private Sub MSFlexGrid1_Click()
     giDealNum =  MSFlexGrid1.TextMatrix( MSFlexGrid1.Row, 0)
     getGridInfo giDealNum     'Send Deal Number and Load Customer info screen
End Sub

explanation of MSFlexGrid1.TextMatrix( MSFlexGrid1.Row, 0):

this means that your getting the value on the selected row and on column 0 (column number depends on the column value that u want to get)

i hope this could give u idea.

game-master
of the flexgrid.

0
Independent Software Vendors: 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:md0333
ID: 22947356
already tried this... If the grid does not have focus when I click on it... No matter where I click on the grid it always comes back with row 1. So even if I click on row 10... It comes back 1. Once the grid has focus everything works great.
0
 

Author Comment

by:md0333
ID: 22955085
OK... I've figured out what is causing the problem. Now I need help to figure out how to do what I want to do...

Once again, I have a grid with about 10 fields of information on it. When the user clicks on the grid it will load all of that information plus a lot more related to that Deal number in textboxes above the grid. If the user needs to change any information they can do it from the textboxes and on the Lost_focus event of those textboxes it will update the DB and then refresh the grid to match the information that has just changed.

If the lost_focus of a textbox goes to the next textbox everything is great. The DB updates and the grid refreshes properly. But if the user moves from one of those textboxes straight to the grid the DB updates and the Grid Refreshes but the on_click event of the grid doesn't happen until after the grid has been refreshed and then it just brings back the 1st row, 1st field value... Why?

I would think that the lost_Focus event of the textbox would be complete before the on_Click of the grid happens. I'm not sure why that 1st click in the grid is not working properly.
 
0
 
LVL 13

Accepted Solution

by:
game-master earned 2000 total points
ID: 22956114


good morning!
that is what the flexgrid works..everytime the flexgrid was on focus the 1st column and 1st row is always selected.

i suggest that u need to create a variable that holds the selected row.
And finally put the cursor on the row( variable holds) when u got the
gotfocus event.


game-master
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Suggested Courses
Course of the Month17 days, 10 hours left to enroll

829 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