Sel Functions on a Form

  • Thread starter Thread starter GRayL
  • Start date Start date
G

GRayL

It is very strange that when the source object of a
subform is a table, one as access to the four sel
properties. When it is a query, these properties
disappear from the collection. My question is how do I
determine, in code, the height and width of a selected
area of a query imbedded in a subform - ie, the source
object is a query?

When the object is a table in datasheet view, the line of
code "Screen.ActiveForm.sfmName1.form.selheight" works
just fine. When the souce object is a query in datasheet
view, that same line of code fails. I get a runtime
error "2455 you have entered an expression that has an
invalid reference to the property SelHeight". I have
spent days examining all the properties of all the
controls of the form to no avail.

Thanks,

Ray
 
SelHeight should return the # of records selected in the datasheet,
regardless of whether it is based on a table, or a query. I can't see the
nature of the data source, possibly making any difference to the operation
of that property.

Be careful with screen.activeform in conjunction with subforms. From a
subform, I believe it refers to the main form (not the subform) (but I don't
have Access here to check). Better to do this:

From the main form:
me![sfmName1].form.selheight
(assuming sfmName1 is the name of the subform >control< on the main
form)

From the subform:
me.selheight

HTH,
TC
 
TC: Been there, done that. I have Office 2000 running
under XP Home. When I imbed a table in a subform, I can
get the dimensions of the highlighted area
programatically. When I do the same for a query, I get
the runtime error 2455 as below. Try it yourself and see
if it happens to you. Create a query of a table
eg. "select * from Table1;". First imbed Table1 -
Me!sfmForm1.SourceObject = "Table.Table1"
The dimensions are all available.
Now, imbed that query programatically -
Me!sfmForm1.SourceObject = "Query.Query1"
Tell me if you get the sel functions. If it works for you
my Access 2000 installation is bad!

Ray
-----Original Message-----
SelHeight should return the # of records selected in the datasheet,
regardless of whether it is based on a table, or a query. I can't see the
nature of the data source, possibly making any difference to the operation
of that property.

Be careful with screen.activeform in conjunction with subforms. From a
subform, I believe it refers to the main form (not the subform) (but I don't
have Access here to check). Better to do this:

From the main form:
me![sfmName1].form.selheight
(assuming sfmName1 is the name of the subform
control< on the main
form)

From the subform:
me.selheight

HTH,
TC


It is very strange that when the source object of a
subform is a table, one as access to the four sel
properties. When it is a query, these properties
disappear from the collection. My question is how do I
determine, in code, the height and width of a selected
area of a query imbedded in a subform - ie, the source
object is a query?

When the object is a table in datasheet view, the line of
code "Screen.ActiveForm.sfmName1.form.selheight" works
just fine. When the souce object is a query in datasheet
view, that same line of code fails. I get a runtime
error "2455 you have entered an expression that has an
invalid reference to the property SelHeight". I have
spent days examining all the properties of all the
controls of the form to no avail.

Thanks,

Ray


.
 
Hi Ray

Sorry for the late reply. I've been teaching some folks to scuba dive, &
that takes some full-time days :-)

You need to tell me why you say that the Sel functions "don't work". Don't
be mislead by having a button which, when clicked, displays the values of
me.seltop and me.selheight! When you click that button, the focus moves away
from the selected records, onto the button, before the click event occurs.
So the two Sel values will always be 0, when that event fires. But this
would be the same regardless of whether the recordsource was a table, a
query, or a SELECT statement.

If this problem is still relevant to you, please give me more detail on
exactly what your are doing. And in particular, how & when you are checking
the values of the Sel properties. I'm sure we can work this out :-)

Cheers,
TC


GRayL said:
TC: Been there, done that. I have Office 2000 running
under XP Home. When I imbed a table in a subform, I can
get the dimensions of the highlighted area
programatically. When I do the same for a query, I get
the runtime error 2455 as below. Try it yourself and see
if it happens to you. Create a query of a table
eg. "select * from Table1;". First imbed Table1 -
Me!sfmForm1.SourceObject = "Table.Table1"
The dimensions are all available.
Now, imbed that query programatically -
Me!sfmForm1.SourceObject = "Query.Query1"
Tell me if you get the sel functions. If it works for you
my Access 2000 installation is bad!

Ray
-----Original Message-----
SelHeight should return the # of records selected in the datasheet,
regardless of whether it is based on a table, or a query. I can't see the
nature of the data source, possibly making any difference to the operation
of that property.

Be careful with screen.activeform in conjunction with subforms. From a
subform, I believe it refers to the main form (not the subform) (but I don't
have Access here to check). Better to do this:

From the main form:
me![sfmName1].form.selheight
(assuming sfmName1 is the name of the subform
control< on the main
form)

From the subform:
me.selheight

HTH,
TC


It is very strange that when the source object of a
subform is a table, one as access to the four sel
properties. When it is a query, these properties
disappear from the collection. My question is how do I
determine, in code, the height and width of a selected
area of a query imbedded in a subform - ie, the source
object is a query?

When the object is a table in datasheet view, the line of
code "Screen.ActiveForm.sfmName1.form.selheight" works
just fine. When the souce object is a query in datasheet
view, that same line of code fails. I get a runtime
error "2455 you have entered an expression that has an
invalid reference to the property SelHeight". I have
spent days examining all the properties of all the
controls of the form to no avail.

Thanks,

Ray


.
 
Back
Top