Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using a Grid for 2 different RecordSources
Message
 
 
To
11/10/2004 10:02:15
Mike Smith
Doncaster Office Services
Oakville, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00950408
Message ID:
00950485
Views:
15
Found this in my possession
********************************************************************
*  Description.......: ChangeGridSource - allows to change grid's record source in design-time
*  Calling Samples...: 
*  Parameter List....: tcNewRecordSource
*  Created by........:   Dorin Vasilescu  #039247
*  Modified by.......: 
********************************************************************
PROCEDURE ChangeGridSource
LPARAMETERS tcNewRecordSource
LOCAL lnSelObjectCount, loGridRef, lnCnt
LOCAL ARRAY laSelectedObject[1], laColumnSources[1]
lnSelObjectCount = ASELOBJ(laSelectedObject)
IF m.lnSelObjectCount = 0
	WAIT WINDOW 'Select a grid in Form Designer first' nowait
	RETURN
ENDIF
if vartype(m.tcNewRecordSource)<>"C"
   tcNewRecordSource = rbInputBox('Type New RecordSource for grid','New Record Source','BldMstr')
endif
if empty(m.tcNewRecordSource)
   return .f.
endif       
loGridRef = laSelectedObject[1]
IF loGridRef.BaseClass <> 'Grid'
	WAIT WINDOW 'One Grid object must be selected' nowait
	RETURN
ENDIF
IF loGridRef.ColumnCount>0
	DIMENSION laColumnSources[loGridRef.ColumnCount]
	FOR lnCnt = 1 TO loGridRef.ColumnCount
		laColumnSources[m.lnCnt] = JUSTEXT(loGridRef.Columns(lnCnt).controlsource)
	NEXT
ENDIF
loGridRef.RecordSource = m.tcNewRecordSource
FOR lnCnt = 1 TO loGridRef.ColumnCount
	IF !EMPTY(laColumnSources[m.lnCnt])
		loGridRef.Columns(m.lnCnt).ControlSource = m.tcNewRecordSource+'.'+laColumnSources[lnCnt]
		loGridRef.Columns(m.lnCnt).setall('ControlSource',m.tcNewRecordSource+'.'+laColumnSources[m.lnCnt])
	ENDIF
NEXT
>I have a data file TRANSACTIONS1 that is handled with a Grid called Grid1.
>
>I would like to be able to use the same Grid to handle a file of same structure TRANSACTIONS2.
>
>I constructed Grid1 to make no reference to the data file in the ControlSource property for each column. e.g. instead of calling the ControlSource Transactions1.Price, I just called it Price.
>
>I then saved Grid1 and Grid2 and changed the RecordSource to TRANACTIONS2, I then found that the RecordSources for each column had disappeared.
>
>Is there some way of constructing a Grid so that it can be modified to handle a different RecordSource without having to retype all the ControlSources for each Column?
>
>Mike Smith
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform