Creating new textbox at run time

R

Ray Pixley

Is it possible to use VBA to create a new textbox at runtime? the code I'm
using is

Private Sub NewButton_DblClick(Cancel As Integer)
Dim aaa As Access.TextBox
Set aaa = New Access.TextBox
....
' (eventually in another routine I'll use Set aaa=Empty)
End Sub

I keep getting the message "Run Time Error '492'. ActiveX component cannot
create an object." The help for that error message is no help.

I want to use it to create and manipulate bookmarks on images without
changing the image, so I only need the manipulation properties (top, left,
move, etc.) and a transparent center. I need to be able to create and
delete them, perhaps many of them, as the images are changed. Otherwise, I
need just the manipulation (top, left, move, etc.) and bordor (red, green,
dotted) properties or methods and a transparent center.

I've tried the line object as a substitute since a textbox might be
overkill, but no joy.

Thanks
 
D

Douglas J Steele

Do you really need to add a new textbox, or can you have a hidden one that
you make visible when you need it?

If you really do need one, take a look at the CreateControl method.
 
R

Ray Pixley

Douglas J Steele said:
Do you really need to add a new textbox, or can you have a hidden one that
you make visible when you need it?

Definitely yes. But I'll eventually need many of them, i.e. I antiticapte
that one image may have more than 100 bookmarks on it, others just 1 or 2.
And I want to be able to create or set to nothing such instances almost at
whim. I'll freely admit it's a resource and memory management problem, but
creating many instances in an organized fashion is possible. Say something
like " Dim aaa(100,10) As TextBox". But right now, I can't instantaneorize
(if that's a word) just one.
If you really do need one, take a look at the CreateControl method.

Didn't know about that method. Looks like I have some reading to do.

Thanks
 
L

Larry Linson

You aren't under the impression that you can add a Text Box to the image
itself, are you? Seems to me that you are going to have to save a lot of
information along with the image, so you can re-create that image's Text
Boxes every time it is displayed.

If you'd start with what it is you are trying to accomplish, rather than how
you think you might accomplish it, someone may be able to be of even more
help. Or, someone may tell you that another product would be better for what
you want to do.

Larry Linson
Microsoft Access MVP
 
R

Ray Pixley

No, I want the textbox (or perhaps an acRectangle) to overlay the image when
it is displayed, and not stored as part of the image. That's why I want the
center of the rectangle to be transparent. Also, sometimes, I may want only
some of the rectangles displayed and depending on the situation, with
different colored borders. I plan to store the bookmarks that relate parts
of one image to parts of another image, in a separate table.

I did think about storing that information within an image, and the only
"open source" format that I could do that with is *.tif. But for reasons
justifiable only to Microsoft, Access doesn't support tif, so that option is
out. There is also a chance that I may not be allowed to store such
information within an image.

Please don't advise using some "proprietary" format or a mass market
product.. They end up being nothing but trouble, their features are way
overexaggerated, and in the long run they are unsupported. The only reason
I'm using Access is that it has some programming ability and it won't break
my budget.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top