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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Zoom in/out of Map

Status
Not open for further replies.

Hookstrat

Technical User
Jun 11, 2002
43
US
I'm building a database for recordkeeping and maintenance. I have a map of relatively poor quality in a form just to give a schematic view of where things are located. Would it be possible to build in a zoom in/out feature. I'm using scanned pics of a real map which I saved as bitmaps and then just cut/pasted into my table. The file sizes are rather large but Access 2000 kept freezing when I tried to use .jpeg format. I'm using a bound object frame with inserted pics. Any ideas/help/advice would be greatly appreciated. Thanks in Advance,
Luke Hoekstra
 
I leave the images on the hard drive, Server drive preferrably
Then I use this code to load it in an Image on a form.
This does 2 things allows you to view different formats i.e. .gif or .jpg
And keeps your database small because your are not adding images which will bloat it in a hurry.

1. So create a form whose record source is connected to your table
2. Add an Image control to the form
3. Properties of Image as follows:
Picture (none)
Picture Type linked
4. Put this code in the On_Current event of the form

Private Sub Form_Current()
If Me![ID] <> 0 Then

Me!Image14.Picture = &quot;p:\ViewPhotos\Photos\&quot; & Me![ID] & &quot;.jpg&quot;
Label20.Caption = &quot;File: &quot; & &quot; p:\ViewPhotos\Photos\&quot; & Me![ID] & &quot;.jpg&quot;
End If

End Sub

Also I used a unique ID for the Pictures name so when I click the naviagation buttons it would get the unique ID from the database and then load that picture.
I also added a label so you know which image it was trying to load (for troubleshooting)

DougP, MCP
 
Thanks Doug but your solution goes a little beyond my grasp of VBscripting. Do I have to create a field called ID in my table and then link my pics from a directory called &quot;c:\viewphotos\photos\&quot;??? It says it can't find &quot;Image14.Picture&quot; within that field. I solved my zoom in/out problem by just using a commmand button which opened a seperate form with a full-sized view of my map. But it would be nice to conserve on disk space as I will be having 3 images for every record in my database (roughly 1,000 records total). Suggestions welcome! Thanks Again,
Luke Hoekstra
 
The ID field can be any unique number for each picture.
If you don't have a unique ID then YES you have to create one.

To do this open the table in design view then add a Autonumber field, when you close and save the table and reopen it, each item will be given a unique number starting with 1.
As you add new pictures the next number will be automatically assigned to each.

Image14 is the name of my Image box
you need to substiute your Images name.

Ther directory can again be anything, I just pasted the code from my form into &quot;Tek-Tips&quot; for you. DougP, MCP
 
Ok I pretty much understand all of that...but won't my pictures still be embedded in my table when I &quot;add&quot; them?? Is this just avoiding having to store them a SECOND time inside the form?? If so, it's o.k. I will try to implement your solution. Thanks for the help.
Luke Hoekstra
 
Still having trouble with linking images. I have a table with two fields... [Map] which contains linked maps from the directory &quot;c:\mydocuments\sanitarymaps&quot; and [ID] which is just an autonumbered field. All of my maps are saved as the corresponding records autonumber. So the first record is simply &quot;1.jpg&quot;. I have a bound image control named Map and I set the form's properties as &quot;Picture - (none)&quot; and &quot;Picture Type - Linked&quot;. Then I put this code into the On_Current Event of the form.
Code:
Private Sub Form_Current()
If Me![ID] <> 0 Then
           
        Me!Map.Picture = &quot;c:\MyDocuments\SanitaryMaps\&quot; & Me![ID] & &quot;.jpg&quot;
    End If

End Sub
[\code]
Unfortunately the debugger keeps saying: Run-time error &quot;438&quot; - Object doesn't support this property or method.  How can I get Access to automatically display the correct picture in my form??  If someone can tell me what I am doing wrong I would really appreciate the help.  Thanks in advance for any suggestions.                L.H.
 
I used the above example and it works, but if a record does not have a picture on file to load, the last picture remains in the image control. How can I make this control not visible if there is no image file matching the unique ID requested? It only changes when there is a different picture to load. Any ideas will be most appreciated!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top