Senin, 04 Maret 2019

Re: [MS_AccessPros] Placing 30,000 images. Now it works.

 

ps, you probably want to use the web browser control on the ribbon instead of the ActiveX control for better compatibility

On 3/4/2019 12:16 PM, crystal 8 strive4peace2008@yahoo.com [MS_Access_Professionals] wrote:
hi Peter,

> " the detour with htm code is not necessary"

wow, you're absolutely right! I didn't even think to try that! Nice to know, thanks!

HTML = Hypertext Markup Language
is NOT "code", it is "markup" (common language with extra information).
Code can run programs; HTML cannot do that. One would use something else like JavaScript to automate a web page.

Rather than checking for offline or online in code, add a textbox with a default value for a base path (txtBase) so it is automatically filled when the form is opened, such as:
="http://www.fotohistoricum.dk/rods/samling/"

If the user wants to be offline, they can change the path to a local location, followed by \ (control AfterUpdate event can add it if it is missing, or you could have them browse to a location and add it then). Then the address for the web browser control would use "\" instead of "/" to separate folder and file name.

It would also be a good idea to create another field in the table for folder name (Foldr). There is no reason for the code to constantly calculate it. You can use an update query to populate this column from your filenames:

UPDATE [MyTablename]
SET [Foldr] = Left([LBNR], 2)

Then the address is this:
[txtBase] & [Foldr] & "/" & [LBNR]
or
[txtBase] & [Foldr] & "\" & [LBNR]   'for local path

~~~
> "I have to resize all the files to the size of the window"

To do them all at once, you can loop files and use code to resize.

VBA > Image > Resize Image WIA
http://msaccessgurus.com/VBA/Code/WIA_ResizeImage_GG.htm

or

VBA > Image > Resize Image Irfanview
https://msaccessgurus.com/VBA/Code/Irfanview_ResizeImage.htm

modify:
VBA > File > Loop and Rename
https://www.msaccessgurus.com/VBA/Code/File_LoopRenameDate.htm

---
you could also make 2 sizes of pictures, or more ... then the form could let them pick what image size they want, in case they have a large or small monitor.

~~~

very nice picture! I can see how your program will be a great source of joy and history for many.

~crystal

free code you can use in your projects
https://msaccessgurus.com/code.htm


On 3/4/2019 6:26 AM, Peter Randløv  [MS_Access_Professionals] wrote:
Hi Crystal
That is correct!
[LBNR] is the Id for each post and file with name [LBNR].jpg, and the folder names are the two first characters.

Coincidentally I discovered that the detour with htm code is not necessary.
The browser window in Access accepts an URL like:
http://www.fotohistoricum.dk/rods/samling/PR/PR2176.jpg
as control element.
It works in Chrome as well. Try to copy the URL above to your browser. The image is an example from the database. It's the royal family in 1899.

Right now I have two problems:
1. It is necessary to check if the URL exists. I need e.g. a function like URLExists(billedURL) to replace IF dir(billed) = "" Then in the offline version of the db:

Private Sub Form_Current()
   Dim billedURL As String
billedURL = "www.fotohistoricum.dk/rods/samling/" & Left([LBNR], 2) & "/" & [LBNR] & ".jpg"
If URLExists(billedURL) Then     'or If URLExists(billedURL) = True Then
   With Me.Webbrowser20
      .ControlSource = "=" & """" & billedURL & """"
   End With
Else
billedURL = "www.fotohistoricum.dk/rods/samling/" & Left([LBNR], 2) & "/" & [DUBLETNR] & ".jpg"
   With Me.Webbrowser20
      .ControlSource = "=" & """" & billedURL & """"
   End With
End if
End Sub

I have googled several options, but non of them work. I keep trying. Do you have any suggestions?

2. The second problem is not essential. It is not possible in the Access browser to fit the image to the window, so I have to resize all the files to the size of the window. This night be the solution.

Regards
Peter
Peter Randløv  
Den 04-03-2019 kl. 06:17 skrev crystal 8 strive4peace2008@yahoo.com [MS_Access_Professionals]:
 

hi Peter,

That is helpful, thanks.
so [LBNR] is the file name? And the folder name is the same as the first 2 characters?

~crystal

On 3/1/2019 7:06 AM, Peter Randløv  [MS_Access_Professionals] wrote:
Hi Crystal
I am not sure I understand your first remark, I don't have duplicate fieldnames.

Currently the structure is:
X:\\...\RODS\SAMLING\AD, AL ...WH.
90 directories where the 30,000 image files are stored e.g. AD0001.jpg, AD0002.jpg ...
The current code for one of the forms (pre defined query) is (where LBNR is the identification for the record e.g. AD0001):

On Error GoTo Message
Dim Billed As String
Billed = strSAMLINGdrev & Left([LBNR], 2) & "\" & [LBNR] & ".jpg"  'strSAMLINGdrev is the path to wherever the user has placed DB and images made by a function when the DB opens
                                                                                                                        'Billed (image in Danish) can e.g. have the value X:\\...\RODS\SAMLING\AD\AD0001.jpg
If Dir(Billed) = "" Then
Billed = strSAMLINGdrev & Left([DUBLETNR], 2) & "\" & [LBNR] & ".jpg"    'Check for a duplicate If the image is not found
End If
If Dir(Billed) = "" Then
    Me.Image12.Picture = strSAMLINGdrev & "BilledetIkkeFundet.jpg"      '"PictureNotFound.jpg"
End If
If Dir(Billed) = [LBNR] & ".jpg" Then
    Me.Image12.Picture = strSAMLINGdrev & Left([LBNR], 2) & "\" & [LBNR] & ".jpg"
Else: Me.Image12.Picture = strSAMLINGdrev & Left([DUBLETNR], 2) & "\" & [DUBLETNR] & ".jpg"
End If
Exit Sub
Message:
MsgBox "Filen ikke fundet. Indsæt USB stick"     '"File not found. Insert USB stick"
End Sub

When the images are copied to a server I will keep the structure:
MyHomepage.dk/../RODS/SAMLING/AD, AL ...WH

So in the VBA code I will have a string e.g.
Dim ImageURL As String
ImageURL = "MyHomepage.dk/../RODS/SAMLING/" & Left([LBNR], 2) & "\" & [LBNR] & ".jpg"

Using
.ControlSource = "=" & """" & ImageURL & """"
for the Web browser in Access it should work.

Hopefully, it answers your question.
Best regards
Peter

Den 01-03-2019 kl. 05:54 skrev crystal  [MS_Access_Professionals]:
 

hi Peter,

great! As you can see, in a query, a column is table.field whereas a form control name might be just a fieldname. In the case where 2 fieldnames are the same (which is a bad idea), the dot becomes an underscore since dot is not a legal character in a controlname.

Please give me a few examples of how you currently store your path and filenames, thanks

~crystal

On 2/28/2019 9:16 AM, Peter Randløv [MS_Access_Professionals] wrote:
Hi again!
Now it works!!!!
I deleted several lines of VBA code, so now it looks like:

Private Sub Form_Current()
   With Me.Webbrowser20
      .ControlSource = "=" & """" & [picURL] & """"
   End With
End Sub

Are there any problems by doing so?
Regards
Peter

Den 28-02-2019 kl. 13:58 skrev Peter Randløv [MS_Access_Professionals]:
 

Thank you very much Crystal, I am impressed by you energy.
I will now stick to the method in your samples, they can give the result I want.
I am now trying to implement the method in a test version of my DB, which I first converted from Access 2003 to 2013.
In the main table "AlleSamlere" I made a column "picURL" (with some random URLs for practice).
In one of the forms I placed the webbrowser with AlleSamlere.picURL as control element, and copied your VBA code to the relevant place for the form.
The form is opened with input from a combo box with a query as post source.
However, when I try to open the form the VBA code stops at "With Me.AllleSamlere.picURL".
It says "Compile error. Methods or data member not found"
But after Stop/Reset/Run the form is displayed correct showing the page for the URL in the tabel "AlleSamlere". Strange!
If I type the VBA code line "With Me. " a drop box appears with several options, but "picURL" or "AlleSamlere.picURL" are not in the listing. This might be the problem?
The only thing I can think of for the time being is, that the transfer from mba (2003) to accdb (2013) has some errors. Is that possible?
Do you have any suggestions?
Best regards

Peter 
Den 27-02-2019 kl. 01:15 skrev crystal 8 strive4peace2008@yahoo.com [MS_Access_Professionals]:
 

hi Peter,

> "send" the image ID (like AB1234 or AB1234.jpg) to the server "

I believe so. I cannot help you do that without researching and experimenting, which is above expectations for a free forum. I suggest you look at getting professional help. Hopefully what has been done so far will be a good foundation.

have an awesome day,
crystal

free code you can use in your projects
https://msaccessgurus.com/code.htm

On 2/26/2019 9:58 AM, crystal [MS_Access_Professionals] wrote:
hi Peter,

> " images are placed in 90 directories"

that is what I wanted to know, thanks! Your English is very good!

By the way, take care not to include personal contact information like phone and address when you post -- I've been removing it when I respond. Perhaps it is a saved signature and you can choose an option not to show it?

~crystal

On 2/26/2019 2:26 AM, Peter Randløv randlov [MS_Access_Professionals] wrote:
Hi Crystal
I am not sure I understand your question concerning categories.
The posts in the database have an ID like AB1234 (and the associated image will be AB1234.jpg).
The images are placed in 90 directories
...\RODS\AB
...\RODS\CD
etc.

Thank you for your tip concerning Filezilla, it will be useful.
However, my question was not file transfer as such. It was about avoiding to make 30,000 htm files - one for each image.
So I am hoping that there is a way to "send" the image ID (like AB1234 or AB1234.jpg) to the server when the browser window in Access looks for e.g. http://www.myhomepage.dk/.../RODS/AB/AB1234.htm.
English is not my mother tongue, so my questions might not be correct formulated.

Best regards
Peter

Den 25-02-2019 kl. 22:25 skrev crystal  [MS_Access_Professionals]:
 

hi Peter,

to keep images path shorter, I am going to use "img" for the directory name. It will take a few days to put the code together because I have other things to do too. Are your images in categories?

~crystal

On 2/23/2019 2:19 PM, crystal  [MS_Access_Professionals] wrote:

Peter, I'm not sure how you transfer files. I use FileZilla, which lets you right-click on a folder and transfer it, as well as everything below, to the web server. So creating folders for categories would be pretty easy to transfer too -- it will just take some time for the computer to do it, but you can do something else while that happens.

FileZilla is a free FTP (File Transfer Protocol) program.
https://filezilla-project.org/

here is a screenshot showing how I propose you structure your images and HTML files where Category1, Category2, etc, would hold the HTML files and the images would be in the respective image folder below. Maybe you already have them in separate folders?

~crystal

On 2/23/2019 11:03 AM, crystal  [MS_Access_Professionals] wrote:

hi Peter,

you're welcome and thank you.

Rather than using www.myhomepage.dk/RODS/PR/PR1234.htm, it would be better to preface the link with http://  or https:// for a secure link, if your web service allows that. Put one of them on your website and then click in the URL bar to copy the link to see what it actually says, such as http://myhomepage.dk/RODS/PR/PR1234.htm

I will make an example to generate the HTML files on your computer. Then you would only need to transfer them to your web site. You should consider putting the images into categories so you don't have 30,000 files in the same directory. It will be a lot easier to manage.

~crystal

On 2/23/2019 9:35 AM, Peter Randløv  [MS_Access_Professionals] wrote:
Crystal
Thanks again, it has been most rewarding to study your samples.
I will now try following:
1. One of the queries generates a new table with a column with the image ID for the selected images e.g. PR1234, AD5678, ...
2. The query opens a form with all information and the image. The present picture box is replaced by a controlelement for webbrowser with the path for the htm code as controelement. The path is generated by the associated module and will for the first image be: www.myhomepage.dk/RODS/PR/PR1234.htm
3. On the server there will be a htm code for each image, in this case PR1234.htm with the text <html><img src="PR1234.jpg">.
This code is only 28 bytes, so it's not a problem having 30,000 of them, but it is not the most "elegant" solution?
Is it possible to pass the image ID (e.g. PR1234) on to the server, or is the small htm file neccesary for each image?
Regards
Peter

Den 22-02-2019 kl. 17:19 skrev crystal  [MS_Access_Professionals]:
 

perfect, Peter! Then you're set!

I updated the example and put it here:
http://www.msaccessgurus.com/tool/WebBrowserControl/WebBrowserControl_DisplayImages_s4p.zip

This one also shows the simplest example of the HTML you could create. The longer HTML examples were done in case you want all the metadata, although I left out keywords in the Head, which you may want

When you are looking at an HTML page, you can often press Ctrl-U to see the page source ... not in Access, but if you put the link it is rendering into your browser.

~crystal

On 2/22/2019 9:47 AM, Peter Randløv randlov [MS_Access_Professionals] wrote:
Hi Crystal
I first now realise that the mail below was to me.
All the 30,000 images are seperate jpg-files. They are not in the database, because I want the users to be able to use the images for other purposes.
Did I understand your comment correct?
Best regards
Peter Randløv  
Den 21-02-2019 kl. 02:22 skrev crystal  [MS_Access_Professionals]:
 

you're welcome, Dave (Peter!)

the next step would be to save the images from the database as files. If
you upload a sample with a couple images, I can see what code can work.

~crystal

On 2/20/2019 5:52 PM, Dave Williams 
[MS_Access_Professionals] wrote:
> Thank you Crystal, Access 2010 opens it OK.
> Regards,
> Dave W
>
>
> On 20/02/2019 16:28, crystal
> [MS_Access_Professionals] wrote:
>> You should be able to open it with 2010. Access 2003 didn't have a web
>> browser control.
>>
>> If folks don't have Access, then Runtime can be used, which could be
>> included in a download for them.
>>
>> On 2/20/2019 5:43 AM, Dave Williams
>> [MS_Access_Professionals] wrote:
>>> What version of Access is that? I can't open it with Access 2003, like
>>> the OP has. Can Access 2010 open it?
>>> Regards,
>>> Dave W
>>>
>>> On 18/02/2019 18:43, crystal
>>> [MS_Access_Professionals] wrote:
>>>> Hi Peter,
>>>>
>>>> I put an example database showing how to display an image from the web
>>>> using Access here:
>>>>
>>>> http://www.msaccessgurus.com/Downloads/WebBrowser_ImagePages_s4p.zip
>>>>
>>>> There are two types of web browser controls you can create.. I made a
>>>> form for each one. The first is on the ribbon. The second,
>>>> Class=Shell.Explorer.2, is created by choosing ActiveX from the
>>>> control list and then getting the Web Browser control from there.
>>>>
>>>> the HTML files to display an image look like this:
>>>>
>>>> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>> <html lang="en">
>>>> <head> <!-- this section is optional -->
>>>>    <meta charset="UTF-8">
>>>>    <meta http-equiv="Content-Language" content="en-us">
>>>>    <title>         Form and Popups </title>
>>>>    <META name="description" content="Picture of Form and Popups for
>>>> MyContacts" />
>>>>    <meta name="Author" content="crystal (strive4peace)" />
>>>>
>>>>    <META name="copyright" content="© 2019 crystal long
>>>> (strive4peace)">
>>>>
>>>> <body>
>>>>    <img src="../MyContacts_Popups.png"
>>>>    title="Form and Popups for MyContacts"
>>>>    alt="Picture of Form and Popups for MyContacts"
>>>>    /> <!-- only SRC is necessary -->
>>>> </body>
>>>> </html>
>>>> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>
>>>> ~crystal
>>>>
>>>> VBA code you can use in your projects
>>>> http://msaccessgurus.com/code.htm
>>>>
>>>>
>>>
>>> ------------------------------------
>>> Posted by: Dave Williams
>>> ------------------------------------
>>>
>>>
>>> ------------------------------------
>>>
>>> Yahoo Groups Links
>>>
>>>
>>>
>>
>
>
> ------------------------------------
> Posted by: Dave Williams
> ------------------------------------
>
>
> ------------------------------------
>
> Yahoo Groups Links
>
>
>








__._,_.___

Posted by: crystal 8 <strive4peace2008@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (33)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


SPONSORED LINKS
.

__,_._,___

Tidak ada komentar:

Posting Komentar