> When you say having to bother with the Resize - what are you referring to?
That was an error.
I was thinking of .SizeToFit
> Do you have differently sized images - and your controls are each a different size to accomodate the underlying image?
Yes.
Here's what I'm doing:
I need to be able to instantly visualize a 2-D Plan View of a physical site installation, with the Designations of the outfitting equipment (lighting fixtures, receptacles, junction boxes, telephones, and many hundreds others) automatically appearing in the foreground of the Plan View, based on the filter selected by the user.
The Plan Views that I created (about 50 of them) are Cropped images from Adobe Elements or Photoshop, set to various Scaling factors depending on the complexity and equipment density of the 2-D area being viewed. My program automatically overlays the Designations onto the Plan based on the scaling factor, the X/Y coordinate location of the equipment, does a bunch of Twips math, you know what I mean. It works great, I'm really just optimizing it, speeding it up, shrinking it as much as I can now.
Programs like AutoCad can be used for this sort of thing but I'm a control freak and it I want it to work the way I want it to work :-)
> As a general rule - I'd certainly look to the one control - changing its properties as required.
But .SizeToFit does not work unless you are in the Design View, and I do not want to close, edit, and reopen the view every time the user changes graphics so... multiple views. I only need to build the Form once, so I wrote code to do that:
CODE
Private Sub Create_Image_Controls_in_a_Form_22_Click()
' Open an existing Form. Create a new Control based on an Image .GIF file
Dim MyControl As Access.Control
Dim int1 As Long
Dim strPicture As String
Dim strFormToEdit As String
strFormToEdit = "Form1"
DoCmd.OpenForm strFormToEdit, acDesign
Do
int1 = int1 + 1
Set MyControl = CreateControl(strFormToEdit, acImage)
MyControl.Name = "Image" & int1
MyControl.Top = 5000 + 100 * (int1 - 1)
MyControl.Left = 1000 + 100 * (int1 - 1)
strPicture = Right("000" & int1, 3)
MyControl.Properties("Picture") = "c:\Image Libary\" & strPicture & ".gif"
MyControl.SizeToFit
Loop Until int1 = 50
End Sub
> If your images are linked then you need the source file in position
Yep I got that covered, see above.
> if embedded then your db will indeed grow in size.
Man, will it ever! Sheesh! It was just going gaga. After I cleared the contents and every "Picture" property and switched to the method shown below my database shrunk in size dramatically, less than a third the size. Much faster Compact & Repair duration too.
> As I've mentioned in this question (and others related to it) - there are definite storage choices to eliminate
bloat.
Exactly. This is what I finally decided to use. Note that the Control named Box01 is used as a target.
CODE
Sub TurnOnImages()
Dim db As DAO.Database
Dim rst1 As DAO.Recordset
Dim strControlname As String
Set db = CurrentDb
Set rst1 = db.OpenRecordset("T01_Pictures", dbOpenDynaset)
Do
strControlname = rst1![ControlName]
Me.Controls(strControlname).Visible = False
Me.Controls(strControlname).Picture = rst1![Filename] ' strFilename
Me.Controls(strControlname).Left = Me.Controls("Box01").Left
Me.Controls(strControlname).Top = Me.Controls("Box01").Top
rst1.MoveNext
Loop Until rst1.EOF
rst1.Close
db.Close
End Sub
Huge improvement. Thanks.