UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

2 Pages V  < 1 2  
Reply to this topicStart new topic
> Add Jpgs To Attachment Field In Batch    
 
   
JackLamberton
post Nov 7 2012, 06:04 PM
Post #21

UtterAccess Member
Posts: 39
From: Fremont, CA



Thank you but before I jump into the lake with Bonnie's code, I would like to share with you my environment:
1. Access version 2010
2. Database to be split into front end and back end modules so that the module can run on local machines in a multi-user enviornment
3. My VBA expertise is very limited.

My local table would look like this;

Table tblImages
Field name: StudentID
Field type: Text
Field name: StudentImage
Field type: Attachment
Table property: Primary Key: StudentID

Bonnie's code below with my changes (underlined). I dont know what "FileData" (underlined, italicized and bold) does and where it fits in a table.
And where the code should go? And how and where is it invoked?

Please advise. Thanks.
====================================
Sub LoadFromFile()
Dim mfile
Set db = CurrentDb
Dim rsImages As DAO.Recordset
Set rsImages = db.OpenRecordset("tblImages")

If Not (rsImages.EOF And rsImages.BOF) Then
rsImages.MoveFirst
Do Until rsImages.EOF
rsImages.Edit
Set rsPictures = rsImages.Fields("StudentImage").Value
mfile = rsImages.Fields("StudentID")
mfile = "\\csdfsrv08\campus_wide\ImageStream_2012-13\SchoolData\ImageStream\LID00121111\Images" & mfile
rsPictures.AddNew
rsPictures.Fields("FileData").LoadFromFile mfile
rsPictures.Update
rsImages.Update
rsImages.MoveNext
Loop
End If
Go to the top of the page
 
+
theDBguy
post Nov 7 2012, 06:18 PM
Post #22

Access Wiki and Forums Moderator
Posts: 47,940
From: SoCal, USA



Hi,

FileData is a property (or a field) of the Attachment field. You just use it as is. For best practice, we'll need to add some explicit variable declarations to your code. For example:

Dim mFile As String
Dim db As DAO.Database
Dim rsPictures As DAO.Recordset

Can you post some sample data of what values are stored in the field "StudentID?" The way you have used it in your code above makes it seem like it is the name of the image file. Is that correct? If not, what is the image file name look like and where do you store it?

Just my 2 cents... (IMG:style_emoticons/default/2cents.gif)
Go to the top of the page
 
+
JackLamberton
post Nov 8 2012, 01:30 AM
Post #23

UtterAccess Member
Posts: 39
From: Fremont, CA



StudentID is student identification number - all students have their own unique ID numbers. The file name of student pictures is [studentid].jpg. So the studentid field is used to associate students with their pictures.

My local table would look like this:
[studentid],[studentid].jpg
60101,60101.jpg
61111,61111.jpg
62222,62222.jpg
And so on....

My image folder:
60001.jpg
60101.jpg
60115.jpg
61111.jpg
61181.jpg
62222.jpg
63333.jpg
...

The image folder is stored on a network drive. What I am trying to do is to add image files to the attachment field in local table tblImages.

Hope this makes sense and doable to you?


Go to the top of the page
 
+

2 Pages V  < 1 2
Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 21st May 2013 - 03:02 AM