Showing Fields when user selects criteria

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello Form Masters,
I have a form with a combo box that allows the user to select from
a list of future dates and twenty hidden text boxes. When they select a date,
I calculate number of periods from current date to get a number. what I want
to happen is show make visible the number of text boxes that correspond to
the period. Example they Choose 12/31/2004, I calculate my period to be 2, I
then want 2 of the text boxes to become visible, if the period were three
then three text boxes, etc. This make sense? What would the procedure be to
unhide a certain number of text boxes based of my calcualted number.
 
Jimbo said:
-----Original Message-----
Hello Form Masters,
I have a form with a combo box that allows the user to select from
a list of future dates and twenty hidden text boxes. When they select a date,
I calculate number of periods from current date to get a number. what I want
to happen is show make visible the number of text boxes that correspond to
the period. Example they Choose 12/31/2004, I calculate my period to be 2, I
then want 2 of the text boxes to become visible, if the period were three
then three text boxes, etc. This make sense? What would the procedure be to
unhide a certain number of text boxes based of my calcualted number.
Hi Jimbo, try the following

1. name each of the hidden textboxs with an incremental
number. For example hide1, hide2,..., hiden
2. set up a procedure to show/hide these textboxes using
an argument for the number of periods to make visible

*** code example start ****

private sub ShowPeriod(NumOfPeriods as integer)
dim intIndex as integer

for intIndex=1 to NumOfPeriods
controls("hide" & intIndex).visible=true
doevents
next intIndex

for intIndex=NumOfPeriods + 1 to n ' n=total number of
textboxs
controls("hide" & intIndex).visible=false
doevents
next intIndex
end sub

*** code example ends ***

3. call the above procedure each time you calculate the
number of periods to make visible, passing this number.

*** code example starts ***

dim intPeriods as integer

If cboDates="12/31/2004" then
intPeriods=2
end if

ShowPeriod intPeriods

*** code example ends ***

disclaimer: air code only

Luck
Jonathan
 
Jim said:
I have a form with a combo box that allows the user to select from
a list of future dates and twenty hidden text boxes. When they select a date,
I calculate number of periods from current date to get a number. what I want
to happen is show make visible the number of text boxes that correspond to
the period. Example they Choose 12/31/2004, I calculate my period to be 2, I
then want 2 of the text boxes to become visible, if the period were three
then three text boxes, etc. This make sense? What would the procedure be to
unhide a certain number of text boxes based of my calcualted number.


If you name the hidden text boxes something like txt1, txt2,
etc, then you could use code like:

For K = 1 To 20
Me("txt" & K). Visible = (K <= period)
Next K
 
Marsh said:
If you name the hidden text boxes something like txt1, txt2,
etc, then you could use code like:

For K = 1 To 20
Me("txt" & K). Visible = (K <= period)
Next K

I so liked my method until I saw the efficiency of your
method above!!! :-)

Thanks
Jonathan
 
Back
Top