Luegisdorf
10/28/2005 6:29:00 AM
Hi Douglas
Thank you for your script; This way I tried too, but comparing
formRun.dataSource() with control.dataSource() never match (the control''s
dataSourceNo is about 1 up to 3 and the formRun''s dataSource was 1228 and
higher).
I use now formRun.form().dataSource(control.dataSource()) as Mike has
suggested and it works well. Of course I check before if the control is a
data control or not to prevent from ugly exceptions.
Thank you for your answer
Best regards
Patrick
"DouglasT" wrote:
> i use to prefer the following
>
> static FormDataSource GetFDSFromControl(FormControl _fc)
> {
> int datasourceIDCtrl;
> ClassID ctrlID;
> DictClass dc;
> int iCnt;
> int i;
> int ifrCnt;
> int ifr;
> FormDataSource ret;
> FormObjectSet fobjset;
> FormDataSource fds2;
> FormStringControl xx;
> boolean bHasDataSourceMth = FALSE;
> FormRun fr;
> Object obj;
> ;
> if (_fc) {
> obj = _fc.owner();
> if ((obj) && (SysDictClass::isEqualOrSuperclass(classIDget(obj),
> classnum(FormRun)))) {
> fr = obj;
> ctrlID = classIDget(_fc);
> if (ctrlID) {
> dc = new DictClass(ctrlID);
> if (dc) {
> iCnt = dc.objectMethodCnt();
> for (i=1;i<=iCnt;i++) {
> if ( dc.objectMethod(i) == ''dataSource'' ) {
> bHasDataSourceMth = TRUE;
> break;
> }
> }
> if (bHasDataSourceMth) {
> datasourceIDCtrl = dc.callObject(''dataSource'', _fc);
> if (datasourceIDCtrl) {
> ifrCnt = fr.dataSourceCount();
> for (ifr=1;ifr<=ifrCnt;iFr++) {
> fobjset = fr.dataSource(ifr);
> if ((fobjset) &&
> (SysDictClass::isEqualOrSuperclass(classidget(fobjset),
> classnum(FormDataSource)))) {
> fds2 = fobjSet;
> if ( fds2.id() == datasourceIDCtrl) {
> ret = fds2;
> break;
> }
> }
> }
> }
> }
> }
> }
> }
> }
> return ret;
> }
>
> regards douglas
>
>
> "Luegisdorf" <Luegisdorf@discussions.microsoft.com> schrieb im Newsbeitrag
> news:4E228DCA-D728-4B27-BE09-BEBF663CD3DC@microsoft.com...
> > Hi everyone
> >
> > On a form exists a control boundet to a existing data source and data
> > field.
> > At runtime I want to access the form data source with the handle of the
> > control.
> >
> > I tried this, but I doesn''t get a valid form data source object:
> >
> > formDataSource = formRun.dataSource(myBoundStringControl.dataSource());
> > // after that formDataSource is still null
> >
> > What''s wrong in here. Can you help me?
> >
> > Thank you in advance.
> > Best regards
> > Patrick
> >
>
>
>