Create a bound class

  • Thread starter Thread starter swas
  • Start date Start date
S

swas

Hello,

Is it possible to create a class that is bound to a field?

Any links / help along these lines is appreciated.


Thanks


swas
 
swas said:
Hello,

Is it possible to create a class that is bound to a field?

Any links / help along these lines is appreciated.


Thanks


swas

But what is meant by 'bound to a field'? What is the class's ultimate
purpose?

If by 'bound class', you're hoping you can get the class in the property
list and select a field for its "Control Source", then the answer is no.
But if you do it in VBA... sure. But it'll depend more on what you want
to do with it for us to give the best advice.
 
What do you intend to do with this? A control (not a field) is bound to a
Field in a table of data... classes are not tables of data, they are code.
Fields aren't "bound" to anything except the TableDef.

Are you looking to have a control on a form that uses some data in Class?
This is possible... one way or another, a Class will crunch data of some
sort, but you will still need a way to get that data to the Class (be it an
external pass to the class or as a function of the class to get the data).
But there's no reason you cannot set up a control and use the events of that
controls to interact with a class that will do something to the data.

A little (or a lot) more info...

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
Thanks for the quick responses.

I have two situations.

1) The comctrl slider control and

2) My own generated slider control (Using mouse down / move events) to
emulate a slider control but without having to reference the comctrl lib.

Either works fine, but I want to display the slider in a continuous form
view, so the slider shows the bound setting to its controlsource field.

In other words, as you look down a page of continous controls, you see the
visual position of the slider, and changing one is reflected in the table.

Hopefully I have made sense here...

Thanks again.


swas
 
I'm assuming that your class will return some sort of value for the current
position of the slider. I think the way I would approach this would be to
use the form's BeforeUpdate event to capture the current value of the slider
and (after doing any conversion you might need to turn this into a usuable
value), apply the value to the field in the recordsource of the form.

So, if I have that correct, you do not actually need a control for what you
want to store... the slider will be unbound, and you will "manually" bind it
before the record is saved.

hopefully I'm on track here...
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
Jack,

Thanks for your thoughts.

The problem as I see it is though, that it is only the current record that
has the position set. All other records sliders will jump to the same
position as an unbound control.

I'm only trying to get the visual effect of multiple slider positions.

Classes and are new for me, so I am trying to explore my logic before trying
to actually trial.

I think...


swas
 
I see... that's why you want it bound.

Well, good luck! Far beyond my scope. I haven't the slightest idea how to
go about this one.

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
swas said:
The problem as I see it is though, that it is only the current record that
has the position set. All other records sliders will jump to the same
position as an unbound control.

I'm only trying to get the visual effect of multiple slider positions.

Classes and are new for me, so I am trying to explore my logic before trying
to actually trial.


That is the problem doing this kind of thing. The slider,
however you do it, is just a single control so there is only
one set of properties (value, color, width, etc) that you
can manipulate. To get it to display differently on
different rows in a continuous form, it must be bound to one
or more record source fields.

The way I have done something like that (ghantt chart) is to
use a text box with an expression like:
=String(positionfield, "I")
That will display the letter I the number of times in each
record's position field.

To make that look more like a bar, you need to use a font
that displays a solid block instead of a letter. There is a
public domain font designed to do just that job at:
http://www.mvps.org/access/forms/frm0055.htm

I have not tried to make a mouse dragable slider out of that
but it sounds like you have so it should work.
 
swas said:
Jack,

Thanks for your thoughts.

The problem as I see it is though, that it is only the current record that
has the position set. All other records sliders will jump to the same
position as an unbound control.

I'm only trying to get the visual effect of multiple slider positions.

Classes and are new for me, so I am trying to explore my logic before trying
to actually trial.

I think...


swas

To be honest, I'm not clear why we want to have a custom slider when we
could just use scrollbar builtin to the subforms?

Assuming you really want to go down this path, (note I've never worked
with slider) I would imagine you need to use the AbsolutePosition
property to tell you where you are relative to the first row/last row
and you can set the AbsolutePosition to "move" to that row when the
scroll moves.
 
Thanks for the responses.

I will have to look more closely at what could be involved here, and make a
value decision of time v result - or consider alternative solutions to
providing a visual position effect.

Thanks for the help and thoughts.


swas
 
Marshall Barton said:
The way I have done something like that (ghantt chart) is to
use a text box with an expression like:
=String(positionfield, "I")
That will display the letter I the number of times in each
record's position field.

To make that look more like a bar, you need to use a font
that displays a solid block instead of a letter. There is a
public domain font designed to do just that job at:
http://www.mvps.org/access/forms/frm0055.htm

I have not tried to make a mouse dragable slider out of that
but it sounds like you have so it should work.

I may be able to use the simple bound text box idea, or with

=String(positionfield, " ") & "I"

to make a pointer style rather than bar lookp.

Using this for the continuous form view, and use conditional formatting to
make the actual slider visible and allow slider change by the user for the
current record.

Getting these to align would be difficult using a textbox and spaces, which
would vary for screen resolution... though perhaps the slider could be in the
form footer and not overlaid in the record at all.

I enjoy the pre thinking as much as the doing... :)

Thanks

swas
 
Back
Top