problem when load image files to database..

L

leen

i got a problem with database..when i trying to link the images from
1folder to database using vba coding i've got error 438"object doesnt
support this property or method"....this the code:

Option Compare Database
Option Explicit


Private Sub Command12_Click()
On Error GoTo Err_Command12_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Command12_Click:
Exit Sub

Err_Command12_Click:
MsgBox Err.Description
Resume Exit_Command12_Click

End Sub

Private Sub cmdLOAD_Click()


Dim MyFolder As String
Dim MyExt As String
Dim MyPath As String
Dim MyFile As String
Dim strCriteria As String

MyFolder = Me.SearchFolder ------------->i've got error 438 here!
' Get the search path.

MyPath = MyFolder & "\" & "*." & [Searchextension]------------->i've
got error 438 here!
' Get the first file in the path containing the file extension.
MyFile = Dir(MyPath, vbNormal)
Do While Len(MyFile) <> 0
[OLEPATH] = MyFolder & "\" & MyFile
[OLEFILE].Class = [OLEclass]
[OLEFILE].OLETypeAllowed = acOLELinked
[OLEFILE].SourceDoc = [OLEPATH]
[OLEFILE].Action = acOLECreateLink
' Check for next OLE file in the folder.
MyFile = Dir
' Go to new record on form.
DoCmd.RunCommand acCmdRecordsGoToNew
Loop



End Sub




can anyone help me..i'm blur..
 
B

bob

This code requires textboxes on your form named ‘SearchFolder’, ‘Searchextension’ and ‘OLEClass’ – do you
have these?

For details see the article that this code is derived-from (see step 4 – ‘Create three unbound text box
controls in the form header section of the form’):
http://support.microsoft.com/kb/q158941/

Rather than requiring the user to type the path each time you could show the ‘Browse for Folder’ dialog:
http://www.ammara.com/access_image_faq/browse_for_folder_dialog.html

If you regularly use the same path you could store the choices in a table and present them in a ‘Recent
Paths’ combo box.

Similarly, if you always use the same file-extension this could be hard-coded, or offered as a choice in
a combo-box.


Finally, consider carefully the choice of ‘OLE Linking’. While you might reasonably expect this to only
store a link to the file, if you use compressed image formats like JPEG you may find that you are storing
a potentially huge overhead in the database (many times the original file-size) – a few hundred images
can see you hit the Access file-size limit of 2GB (and even if you stay within this limit the performance
can suffer drastically). It is also highly dependant on having suitable ‘OLE Server’ software for the
file-type installed and correctly registered on the system(s) – this is easily and frequently broken if
you install new software, upgrade Office or use the database on several machines. If you want to actually
‘link’, just store the path/filename (or enough information to generate it at runtime) and display the
image in an Image Control, for example:

Private Sub Form_Current()
Dim ImagePath As String
ImagePath = Me!ImagePathField

If Len(ImagePath) > 0 And Len(Dir(ImagePath)) > 0 Then
Image1.Picture = ImagePath
Else
Image1.Picture = ""
End If
End Sub


Where:
‘ImagePathField’ is a field in the form’s data-source that contains the full path to the image.
‘Image1’ is the name of an Image Control on the form.

If you use this approach then you may need to suppress the ‘Loading Image’ dialog in order to prevent the
‘Scroll-too-Quick’ crash:
http://www.ammara.com/access_image_faq/scroll_too_quick_crash.html



--
_______________________________________________________
DBPix 2.0: Add pictures to Access, Easily & Efficiently
http://www.ammara.com/dbpix/access.html






leen said:
i got a problem with database..when i trying to link the images from
1folder to database using vba coding i've got error 438"object doesnt
support this property or method"....this the code:

Option Compare Database
Option Explicit


Private Sub Command12_Click()
On Error GoTo Err_Command12_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Command12_Click:
Exit Sub

Err_Command12_Click:
MsgBox Err.Description
Resume Exit_Command12_Click

End Sub

Private Sub cmdLOAD_Click()


Dim MyFolder As String
Dim MyExt As String
Dim MyPath As String
Dim MyFile As String
Dim strCriteria As String

MyFolder = Me.SearchFolder ------------->i've got error 438 here!
' Get the search path.

MyPath = MyFolder & "\" & "*." & [Searchextension]------------->i've
got error 438 here!
' Get the first file in the path containing the file extension.
MyFile = Dir(MyPath, vbNormal)
Do While Len(MyFile) <> 0
[OLEPATH] = MyFolder & "\" & MyFile
[OLEFILE].Class = [OLEclass]
[OLEFILE].OLETypeAllowed = acOLELinked
[OLEFILE].SourceDoc = [OLEPATH]
[OLEFILE].Action = acOLECreateLink
' Check for next OLE file in the folder.
MyFile = Dir
' Go to new record on form.
DoCmd.RunCommand acCmdRecordsGoToNew
Loop



End Sub




can anyone help me..i'm blur..
 
L

leen

hi..

actually...i hv follow each step in
http://support.microsoft.com/kb/q158941/ ...but when i run the code..i
still got the same error..can u help me to find another solution to
link the image files from a folder to Access??i really need a
help...plz...i have to link 38000 BMP images...it's a huge number..plz
help me...
 
L

leen

this is my coding..


Private Sub cmdLOAD_Click()


Dim MyFolder As String
Dim MyExt As String
Dim MyPath As String
Dim MyFile As String
Dim strCriteria As String


MyFolder = Me.SearchFolder ------------->i've got error 438 here!
' Get the search path.


MyPath = MyFolder & "\" & "*." & [Searchextension]------------->i've
got error 438 here!
' Get the first file in the path containing the file extension.
MyFile = Dir(MyPath, vbNormal)
Do While Len(MyFile) <> 0
[OLEPATH] = MyFolder & "\" & MyFile
[OLEFILE].Class = [OLEclass]
[OLEFILE].OLETypeAllowed = acOLELinked
[OLEFILE].SourceDoc = [OLEPATH]
[OLEFILE].Action = acOLECreateLink
' Check for next OLE file in the folder.
MyFile = Dir
' Go to new record on form.
DoCmd.RunCommand acCmdRecordsGoToNew
Loop


End Sub
 
B

bob

I can only reiterate that it looks like your textbox names are not correct. Select the 'SearchFolder'
text box on the form and display the properties window - you should see "Text Box: SearchFolder" in the
caption (title bar) of the properties window. If not, click the 'Other' tab and verify that the 'Name'
property (the first property in the list) exactly matches 'SearchFolder' (without the quotes). Correct
it if necessary.

Now go to the code window and delete the text 'Me.SearchFolder'. In its place type 'Me.' then you should
see a popup list - if the name of the textbox is correct you should find 'SearchFolder' in this list.

If all else fails, and you are running a one-off import process, you could hard-code the path and extension,
for example:

MyFolder = "C:\MyImportFolder"

MyPath = MyFolder & "\*.bmp"

(assuming all your images have the extension 'bmp').


If, instead, you want to avoid using OLE, then you can store the full path or just the filename in a text
field and display the image in an Image Control using the code I gave previously. The simplest way would
be to store the full path, i.e. link to the files in their original location, however, if the database
will have multiple users or you will continue adding images from different locations then you may need
to refine this further. In such cases the following articles should give further insight:

Storing Images using Relative Paths
http://www.ammara.com/access_image_faq/image_relative_paths.html

Ensure uniqueness of filenames - Use autonumber fields for image file names
http://www.ammara.com/access_image_faq/autonumber_file_names.html
 
L

leen

thank you bob forthe reply..its really help me..but i hv another
problem..when i hv load all the file..i want to sort the file refer to
the name file..like a103.bmp,a104.bmp,a105.bmp..bcoz when i sort it..i
being like this..a103.bmp,a1031.bmp,a104.bmp,a1041.bmp...can u help
me??
 

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