Ask Your Question
1

macro to get a grid field value for the current record on a subform [closed]

asked 2015-11-09 10:54:35 +0200

jay Arr gravatar image

I have this which works fine for a grid field on a MAIN form

public function getMainformGridField(theEvent as object, FieldName as string) as variant
dim rowset  as object
dim Form    as object

    Form=theEvent.Source.Model.Parent
    rowset=Form.getColumns
    getMainformGridField=rowset.getbyName(FieldName).value
end function

have tried this for a subform

public function getSubFormGridField(theEvent as object, FieldName as string) as variant

dim oMainForm       as object
dim oColumnList as object 
dim oGrid           as object
dim theValue        as variant

    oMainForm=theEvent.Source.Model.Parent
    oGrid=oMainForm.getbyName("SubForm_Grid")
    oColumnList = oGrid.getByName(FieldName)
    theValue=oColumnList.getCurrentValue()
    getSubFormGridField=theValue
end function

But it fails at the oColumnList assignment.

Can anyone help with the correct code please?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-03-14 18:56:50.565229

1 Answer

Sort by » oldest newest most voted
1

answered 2015-11-09 15:01:53 +0200

jay Arr gravatar image

With a bit of experimentation I've sorted it and discovered a working solution

public function getSubFormGridField(theEvent as object, FieldName as string) as variant
dim oMainForm       as object
dim oSubform    as object
dim oColumnList as object 
dim oGrid           as object
dim theValue        as variant

    oMainForm=theEvent.Source.Model.Parent
    oSubform=oMainForm.getbyName("SubForm")
    oGrid=oSubForm.getbyName("SubForm_Grid")   
    oColumnList = oGrid.getByName(FieldName)   
    theValue=oColumnList.getCurrentValue()
    getSubFormGridField=theValue
end function
edit flag offensive delete link more

Comments

Thanks for posting this solution. Getting the value of a subform field has proven difficult. I have my own solution, but it is good to see other solutions too for future reference.

Steve R. gravatar imageSteve R. ( 2015-11-10 00:00:55 +0200 )edit

Question Tools

1 follower

Stats

Asked: 2015-11-09 10:54:35 +0200

Seen: 1,012 times

Last updated: Nov 09 '15