Moving controls programatially

  • Thread starter Thread starter Phill
  • Start date Start date
P

Phill

OK here goes. I am a fairly advanced programmer, but I am having problems
with this one.

I have built a form that is a working two week time span (10 days)
Monday-Friday 2x.
Next I am using a continuous form to show data from a query, now comes the
interesting part.

I want to position one field's control (JobID) under one of the dates (a
left position of 1", 2" etc. depending on the date) and I want the width of
the field to be multiplied by the number of days the items is to exist (both
fields that are returned in my query).

I can get the width to work, but it applies the same width to all items in
the collection, not each item.
(I know I need to iterate though the controls, but how do I get to the one I
need? The JobID)

Also I am having no success with moving the control left or right. I am
using the following code, currently I have it attached to the OnClick event
for the field. I would like to move it to a button when the iteration is
working properly.

Me.JobID.Width = (Me.JobID.Width * Me.HowWide)
Me.JobID.Left = (Me.JobID.Left * Me.StartPOS)

Any help would be greatly appreciated.
 
Phill said:
OK here goes. I am a fairly advanced programmer, but I am having problems
with this one.

I have built a form that is a working two week time span (10 days)
Monday-Friday 2x.
Next I am using a continuous form to show data from a query, now comes the
interesting part.

I want to position one field's control (JobID) under one of the dates (a
left position of 1", 2" etc. depending on the date) and I want the width of
the field to be multiplied by the number of days the items is to exist (both
fields that are returned in my query).

I can get the width to work, but it applies the same width to all items in
the collection, not each item.
(I know I need to iterate though the controls, but how do I get to the one I
need? The JobID)

Also I am having no success with moving the control left or right. I am
using the following code, currently I have it attached to the OnClick event
for the field. I would like to move it to a button when the iteration is
working properly.

Me.JobID.Width = (Me.JobID.Width * Me.HowWide)
Me.JobID.Left = (Me.JobID.Left * Me.StartPOS)


As you have seen, your code works so that's not the real
question. The question is how to do different manipulations
on different rows on a continuous or datasheet form and the
answer to that is, you can't. There is only one control
(one set of properties) that is displayed multiple times.
The only thing that happens differently on different rows is
the value of the bound field and the formatting applied by
the control's Conditional Formatting. You can use
conditional control source expressions that will display the
value of the expression differentlym but that's about it.

OTOH, expressions can do a lot so you might(?) be able to
get things to look pretty much the way you want. For
instance, if you want a color bar to start and end at data
dependent positions, you can use a single text box that
spans the entire width of the form. Then set it's
expression to something like:
=String(Me.StartPOS * scalingfactor, " ") &
String(Me.HowWide * scalingfactor, "A")

That depends on setting the text box's Font to a fixed width
font that contains a character that is a solid block. For a
discussion of the font issue and a custom font created just
for this purpose see
http://www.mvps.org/access/forms/frm0055.htm
 
Marsh, thanks for the input, this saves me many more frustrating hours. Also
you have given me some more food for thought. I have used the background of
two overlaping text boxes in the past to give a status indicator. If I am
understanding your suggestion I could do something like that in a full width
text box and read my string input to essentially move the background color. I
also down loaded the font that you suggested just in case I need it.
Well thanks again for your help I'll let you know if I can get it working.
 
Back
Top