Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default The hunt for the disappearing textboxes.....

Hi all.

I'm (foolishly) creating a multipage userform laid out like a
calendar, which each page being a month. Each day has 11 entries, and
each entry has 2 text boxes. So I have to have 22 text boxes per day,
which for the year adds up to over 8000 textboxes!

Each of these textboxes needs a controlsource set to a specific cell
on a sheet in the wb.

As I see it I have two choices;

Rename 8000 textboxes so that they are easily programmed (names such
as Time1, Time2, Entry1, Entry2) in a loop - then i could set the
controlsource programatically

Or leave the names (these are random in no order, so the first might
be TextBox367 and the next might be TextBox930) and manually set the
controlsource of 8000 boxes!

So - I thought i'd try another way. Start again and write code to add
the 600+ boxes required for one month, and whilst adding giving them
numerical names in order (Time1, Time2, Time3) etc.

However I cannot get this to work. My code;

For i = 1 To 11
nm = "Time" & i
Set mytextbox =
VBAProject.July08.MultiPage1.july.Controls.Add("Fo rms.TextBox.1")
With mytextbox
.Name = nm
.Left = 50
.TOP = 50
.Height = 12.75
.Width = 30
.Visible = True
End With
Next i

is in the userform_initialise.

The textboxes are created....however as soon as I close the userform
the textboxes disappear. I need them to be permanent. (I know I can
create them again next time I initialise the form however I want them
there all the time!).They do not exist when I view the form in design
mode.

Can anybody solve my disappearing textbox mystery please?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default The hunt for the disappearing textboxes.....

As I see it, your two choices aren't good choices - in fact, I would call them both horrible. A
much better choice is to use another control (the Microsoft date and time picker, which is a
calendar control) where you or your user can select the month, and the day. Then you use code like
this in the change event of that date control:

MyR = Math here to select the correct row from your datasheet based on the date selected
Userform1.TextBox1.Text = Worksheets("Database").Cells(myR, 1).Value
Userform1.TextBox2.Text = Worksheets("Database").Cells(myR, 2).Value
Userform1.TextBox3.Text = Worksheets("Database").Cells(myR, 3).Value
etc....

And then use the reverse to change the values if they are edited
Worksheets("Database").Cells(myR, 1).Value = Userform1.TextBox1.Text
etc.

HTH,
Bernie
MS Excel MVP


"anon" wrote in message
...
Hi all.

I'm (foolishly) creating a multipage userform laid out like a
calendar, which each page being a month. Each day has 11 entries, and
each entry has 2 text boxes. So I have to have 22 text boxes per day,
which for the year adds up to over 8000 textboxes!

Each of these textboxes needs a controlsource set to a specific cell
on a sheet in the wb.

As I see it I have two choices;

Rename 8000 textboxes so that they are easily programmed (names such
as Time1, Time2, Entry1, Entry2) in a loop - then i could set the
controlsource programatically

Or leave the names (these are random in no order, so the first might
be TextBox367 and the next might be TextBox930) and manually set the
controlsource of 8000 boxes!

So - I thought i'd try another way. Start again and write code to add
the 600+ boxes required for one month, and whilst adding giving them
numerical names in order (Time1, Time2, Time3) etc.

However I cannot get this to work. My code;

For i = 1 To 11
nm = "Time" & i
Set mytextbox =
VBAProject.July08.MultiPage1.july.Controls.Add("Fo rms.TextBox.1")
With mytextbox
.Name = nm
.Left = 50
.TOP = 50
.Height = 12.75
.Width = 30
.Visible = True
End With
Next i

is in the userform_initialise.

The textboxes are created....however as soon as I close the userform
the textboxes disappear. I need them to be permanent. (I know I can
create them again next time I initialise the form however I want them
there all the time!).They do not exist when I view the form in design
mode.

Can anybody solve my disappearing textbox mystery please?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting up Treasure Hunt spreadsheet Rachael Excel Discussion (Misc queries) 11 September 13th 08 02:06 AM
Active cell hunt Jock Excel Programming 2 December 14th 07 02:56 PM
Show Results in TextBoxes, ONLY if All TextBoxes have Data in them RyanH Excel Programming 3 November 19th 07 03:30 PM
commandbar hunt defj Excel Programming 2 November 17th 03 11:40 PM
Code to Hunt Linked Cells Phil Hageman Excel Programming 2 July 16th 03 01:31 PM


All times are GMT +1. The time now is 09:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"