Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

createcontrol problem

Status
Not open for further replies.

Helen

Programmer
Joined
Mar 3, 2000
Messages
5
Location
CA
I am trying to create a rectangle 'on the fly' and am using the createcontrol function. However I am getting an error message: 'Run-time error '29054': Microsoft Access can't add, rename, or delete the control(s) you requested.' All the buttons, except the End button is greyed on the dialog box that displays this error.<br>
<br>
I hope someone has a solution to this problem<br>
<br>
thanks in advance<br>
Helen Fairweather
 
could you be a little more specific as to what you mean by &quot;creating a rectangle 'on the fly'&quot;?<br>
maybe give a brief example of what you're looking to do on your form.<br>
<br>
thanks. <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
 
What do you want your rectangle to do.<br>
Maybe instead of &quot;Creating&quot; it. Just &quot;re-size&quot; an &quot;invisible&quot; one and turn it &quot;visible&quot;. <p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
In response to Brian Famous:<br>
<br>
I have written a rainfall-runoff simulation model in access and want to design a dynamic interface to show rainfall and runoff as the program steps through each day. Previously i have had lots of problems with using dynamic graphs in Access and thought i would add rectangles and scale them to give an indication of the amount of rainfall and runoff on any particular day.<br>
<br>
I have written the following code to add a rectangle to an existing form, which generates the error message outlined in my original post. If I create a new form and use createcontrol in the same way, the code works. But I would prefer to add the rectangles to an existing form.<br>
<br>
Sub test_des_mode()<br>
Dim new_rect As Control<br>
<br>
<br>
DoCmd.OpenForm &quot;runoff&quot;, acDesign, &quot;&quot;, &quot;&quot;, , acNormal<br>
l_val = 1000<br>
t_val = 2000<br>
wd = 1000<br>
ht = 1000<br>
<br>
<br>
Set new_rect = CreateControl(&quot;runoff&quot;, acRectangle, , &quot;&quot;, &quot;&quot;, l_val, t_val, wd, ht)<br>
<br>
regards<br>
<br>
Helen Fairweather
 
Is'nt odd, Helen that your Last name is Fairwhether and you are dealing with a rainfall project.<br>
<br>
Access is telling you that you cannot create a control so Guess what you cannot &quot;Create a control&quot;<br>
But that does not mean the you cannot end up with the same result.<br>
I looked up an example in Help and it refers to creating control. but it is being done while creating a new form.<br>
<br>
This works:<br>
Me!Box17.Left = 1000<br>
Me!Box17.Top = 2000<br>
Me!Box17.Width = 1000<br>
Me!Box17.Height = 1000<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Doug,<br>
<br>
Any ideas why the createcontrol function will work on a new form, but not an existing one? the code you posted will only work if box17 exists, or am i missing something?<br>
<br>
thanks for your help<br>
<br>
Helen Fairweather
 
I copied the code as written (added an &quot;End Sub&quot;) and it works fine in Access '95. <br>
<br>
Are you using '97 or 2000? <p>Jim Conrad<br><a href=mailto:jconrad3@visteon.com>jconrad3@visteon.com</a><br><a href= > </a><br>
 
This is a great forum. <br>
<br>
Jim,<br>
<br>
I have just discovered that the code will work if i run it from a module, but will not work when associated with a button on the form! I will be able to work around it, but it is very frustrating not knowing why. I am using 2000<br>
<br>
thanks everybody for you help<br>
<br>
Helen Fairweather
 
In Access '95 it works. On &quot;Form1&quot; I placed a button and in the Click event added your code. I open Form1, click the button several times. For each &quot;click&quot; a new box is added to the &quot;runoff&quot; form.<br>
<br>
You aren't trying to run the code from WITHIN the &quot;runoff&quot; form, right? <p>Jim Conrad<br><a href=mailto:jconrad3@visteon.com>jconrad3@visteon.com</a><br><a href= > </a><br>
 
Jim,<br>
Yes, I was trying to run the code from WITHIN the &quot;runoff&quot; form. I have rectified this and it now works! do you know why it will not work WITHIN the &quot;runoff&quot; form?<br>
<br>
Thanks for your help everybody<br>
<br>
regards<br>
<br>
Helen Fairweather
 
You can't use a form in both &quot;design&quot; mode and in &quot;runtime&quot; mode at the same time.<br>
<br>
You could open a secord form from the &quot;runoff&quot; form and have it switch &quot;runoff&quot; to design mode, add the new controls, then open &quot;runoff&quot; in NORMAL mode. <p>Jim Conrad<br><a href=mailto:jconrad3@visteon.com>jconrad3@visteon.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top