Search code examples
visual-foxpro

Select Alias isn't changing to the proper alias


I have a combo box in a grid. The form has a lot of tables (opened in init and assigned aliases). The grid has property

LinkMaster=EVENT

RecordSource is set to HEAT

The column in the grid has controlSource set to Heat.Event_no and the current control is CmbEvent. The CmbEvent control source is set to heat.event_no. Everything works as it should in the grid except...

When I select an item out of the combo box, the following code runs as a procedure called from the Click event:

IF event.relay
 SELECT RELAY
 GO TOP IN RELAY
 SET ORDER TO 
GO OrigRelayRec IN RELAY

....

The issue that I am having is that unless I am stepping through the code, the alias() never goes to RELAY. No matter what alias it starts on (usually HEAT), if I put a break point in at GO TOP, the alias() shows up as EVENT. The only way it ever gets to RELAY is if I step through the code.

Any thoughts on why Select alias isn't actually selecting the alias?


Solution

  • Usually in cases like this I set the focus to a control other than the grid. The problem is since the grid has focus it will always keep the alias selected that's bound to the grids RecordSource.

    So right before your SELECT you can do something like "Thisform.cmdOK.SetFocus()" (it can be any control on your form other than the grid). That should do the trick.