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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Relationship between grid and dropdown box breaks after grid.setfocus

Status
Not open for further replies.

advlaser

Programmer
Aug 30, 2015
2
AU
I've got a fairly simple form with a ComboBox on top with a grid below. The Combobox is tied to the master table and the grid holds the detail records. When I open the form, the relationship between the two work great. I can click on any record in the combo box and the appropriate records appear in the grid. I can edit records fine in the grid and it all works. But if I use the setfocus command with the grid, the relationship breaks and the dropdown no longer changes the values in the grid. I need really need setfocus to work. Any ideas?
grid_mjetxt.jpg

Here is the code for the add form. This code works fine if I comment out thisform.grdTrays.setfocus. Any ideas? Thanks!
Code:
IF NOT EMPTY(thisform.selectedprofile)
	SELECT printertrays
	APPEND BLANK
	replace printertrays.profileid WITH printerprofiles.profileid
	thisform.grdTrays.Refresh
	[COLOR=#CC0000]thisform.grdTrays.SetFocus[/color]
	SELECT printerprofiles
ELSE
	MESSAGEBOX('You have to select a profile first.',64,'Select a Profile')
ENDIF
 
My assumption is a filter condition with a variable going out of scope or a relation with an index order changing.
So how is the realtion set? Did you set a filter on the grid recordsource or a relation from the combobox cursor to the grid cursor?

Bye, Olaf.
 
Also, make sure that's actually the name of the grid. (grdTrays). If it's been changed (copy paste) the name might have changed to a default like Gridbase1.


Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
I've made sure that the grid name is grdTrays. As for the relationship, I found if I add the following code to the click event of the dropdown it works. But it just seems to me that the relationship shouldn't break. The relationship is originally set in the form's data environment. In this case the tables are very small and there doesn't seem to be any penalty for doing so.

Code:
SELECT printerprofiles
SET RELATION TO profileid INTO printertrays

dataenvironment_jmc9hu.jpg


Marvin Masson
 
Maybe you expect something else, but since you add one printertray record for the selected profile, the relation will let the grid display at least that new record.
But if all printer profiles and trays are already in the data there is no reason to add any records. The choice of a printer (profile) should show it's trays.
If this doesn't happen there's too less information about further environment, eg filters or other relations.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top