jthe
10-25-2009, 11:20 PM
Hi All,
thanks for reading this.
My development environment is Access 2003.
I'm currently developing a dynamic form. All of the controls in this form are generated through VBA.
Here is a walk through of my code
1. Form Load
2. Check to remove all controls
dim count as integer
count = myForm.Controls.count
if count > 0 then
for i = 0 to count-1
DeleteControl myForm, myForm.Controls(i).name
next i
end if
3. then createControls method.
In the createControls method, I created a tab object with this syntax:
Dim tabControl as control
set tabControl = Application.CreateControl("myForm",acTabCtl,acDetail)
with tabControl
.name = "Main_Tab"
end with
4. After this tab, I created couple of text boxes
Form works fine if it is the first time i fire the form up, because initialy, there's nothing in the form thus skipping the for loop.
However, if I reload, it will give me
"The control number you specified is greater than the number of controls." message.
Using the debugger, I found out that when acTabCtl is creating a tab object, it created 2 acPage objects as well, and my step#2 DeleteControl method
does not seem to recognize these 2 pages.
Any idea of why it doesnt recognize it ?
My next question is, how do I add pages on to tab and manipulate the pages through VBA ?
Sorry if it's a bit confusing, I hardly do any work in VBA, so really need your help.
Thanks again.
thanks for reading this.
My development environment is Access 2003.
I'm currently developing a dynamic form. All of the controls in this form are generated through VBA.
Here is a walk through of my code
1. Form Load
2. Check to remove all controls
dim count as integer
count = myForm.Controls.count
if count > 0 then
for i = 0 to count-1
DeleteControl myForm, myForm.Controls(i).name
next i
end if
3. then createControls method.
In the createControls method, I created a tab object with this syntax:
Dim tabControl as control
set tabControl = Application.CreateControl("myForm",acTabCtl,acDetail)
with tabControl
.name = "Main_Tab"
end with
4. After this tab, I created couple of text boxes
Form works fine if it is the first time i fire the form up, because initialy, there's nothing in the form thus skipping the for loop.
However, if I reload, it will give me
"The control number you specified is greater than the number of controls." message.
Using the debugger, I found out that when acTabCtl is creating a tab object, it created 2 acPage objects as well, and my step#2 DeleteControl method
does not seem to recognize these 2 pages.
Any idea of why it doesnt recognize it ?
My next question is, how do I add pages on to tab and manipulate the pages through VBA ?
Sorry if it's a bit confusing, I hardly do any work in VBA, so really need your help.
Thanks again.