By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,805 Members | 1,273 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,805 IT Pros & Developers. It's quick & easy.

dynamic forms

P: n/a
Hi,

I wonder if anyone can help with this problem. I have a form with
about 20 different fields which contains info imported from access
(basicly its the results of a questionnaire) some of the fields might
be blank. I want the null fields to be not visable and field below it
to fill the space of the one above it so it doesnt leave any unsightly
gaps.
Also I would like some fields to be the same size as the text in them.
So the size would change dynamicly.

What I need to know is:

Is what I'm asking possible?
How is it done?
Are there any examples on the net?
Thanks for any help

Mar 12 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Ma*********@gmail.com wrote:
be blank. I want the null fields to be not visable and field below it
to fill the space of the one above it so it doesnt leave any unsightly
gaps.
It can be done, but you have to be prepared to write a fair bit of code
that manipulates the .top property of all controls below a question that
is made invisible. This can be a PITA, so the question you have to ask
yourself is "what do I hope to gain doing it this complicated way versus
just displaying null values as 'Not answered'". For example, say a
question is "Do you collect toenail clippings?" and the field name is
[Toenails], you can write, as the controlsource for the corresponding
text box control on your form:

=nz([Toenails],"Not answered by respondant")

Or something similar.

It's simpler and *will* save you a lot of grief and frustration.
Also I would like some fields to be the same size as the text in them.
So the size would change dynamicly.
Easy enough in a report, difficult in a form. Use vertical scroll bars
in your text box.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me
Mar 12 '07 #2

P: n/a
On Mar 12, 5:51 pm, Tim Marshall
<TIM...@PurplePandaChasers.Moertheriumwrote:
Marshall...@gmail.com wrote:
be blank. I want the null fields to be not visable and field below it
to fill the space of the one above it so it doesnt leave any unsightly
gaps.

It can be done, but you have to be prepared to write a fair bit of code
that manipulates the .top property of all controls below a question that
is made invisible. This can be a PITA, so the question you have to ask
yourself is "what do I hope to gain doing it this complicated way versus
just displaying null values as 'Not answered'". For example, say a
question is "Do you collect toenail clippings?" and the field name is
[Toenails], you can write, as the controlsource for the corresponding
text box control on your form:
Yes I want to give it a try. Would like to see an example so I can see
it working.

I think it would make things simpler for my users to not see the
answers than a default message.


=nz([Toenails],"Not answered by respondant")

Or something similar.

It's simpler and *will* save you a lot of grief and frustration.
Also I would like some fields to be the same size as the text in them.
So the size would change dynamicly.

Easy enough in a report, difficult in a form. Use vertical scroll bars
in your text box.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me

Mar 12 '07 #3

P: n/a
On Mar 12, 2:21 pm, Marshall...@gmail.com wrote:
>
Yes I want to give it a try. Would like to see an example so I can see
it working.

I think it would make things simpler for my users to not see the
answers than a default message.
Try writing every field that's not null to a multi-dimensional array.
Once you hit the end you'll know how many fields you have. Do a For/
Next loop and write the values to your generic text boxes (i.e.
Array(X,Y) = txtAnswer1, txtAnswer2, txtAnswer3, etc...)

It's cludgey at best, and a headache at worst. Enjoy.

Mar 12 '07 #4

P: n/a
Ma*********@gmail.com wrote:
Yes I want to give it a try. Would like to see an example so I can see
it working.
OK, here's some air code. I'm assuming you have a form that is a single
form view with a recordsource that has one or more survey responses.
Thus the following code would need to be run in the on current event,
ie, whenever you chnage from one survey response to another.

I'll assume three text boxes, each with a label describing the question
and that the text box is the governing factor in vertical size.

'COde Starts

'Reset all text boxes such that they are in their
'"default position" and visible. To get their "default position",
'Record the .Top property of each text box when you have finished
'laying out the form. I'll assume an inch and a half per text box
'and that each text box is below the previous one,
'ie, 1, then, 2, then 3

dim lngChange as long

Me.txtQuestion1.Top = 1.5 * 1440 '1440 twips in an inch
Me.txtQuestion2.Top = Me.txtQuestion1.Top + 1.5 * 1440
Me.txtQuestion3.Top = Me.txtQuestion2.Top + 1.5 * 1440

Me.txtQuestion1.visible = true
Me.txtQuestion2.visible = true
Me.txtQuestion3.visible = true

'Now check the controlsource of each text box.
'If null, add the top property to lngChange.

lngChange = 0 'initialize

if isnull(me.txtQuestion1) then
me.txtQuestion1.visible = false
lngchange = lngchange + (1.5 * 1440)
end if

if isnull(me.txtQuestion2) then
me.txtQuestion2.visible = false
lngchange = lngchange + (1.5 * 1440)
else 'if visible, adjust it up the lngchange distance
me.txtQuestion2.top = me.txtquestion2.top - lngchange
end if

if isnull(me.txtQuestion3) then
me.txtQuestion3.visible = false
lngchange = lngchange + (1.5 * 1440)
else 'if visible, adjust it up the lngchange distance
me.txtQuestion3.top = me.txtquestion3.top - lngchange
end if

And so on....

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me
Mar 12 '07 #5

P: n/a
On Mar 12, 2:21 pm, Marshall...@gmail.com wrote:
>
Yes I want to give it a try. Would like to see an example so I can see
it working.

I think it would make things simpler for my users to not see the
answers than a default message.
Try writing every field that's not null to a multi-dimensional array.
Once you hit the end you'll know how many fields you have. Do a For/
Next loop and write the values to your generic text boxes (i.e.
Array(X,Y) = txtAnswer1, txtAnswer2, txtAnswer3, etc...)

It's cludgey at best, and a headache at worst. Enjoy.

Mar 12 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.