Microsoft Access 2007-photo album

Create photo album

Access 2007 Photo Album

In your life, you may have a lot of photos that you took with your family, friends, or co-workers. These photos are very good memory. Of course, you can keep your photos in hard copy album and place it in your house. But you are probably difficult when you stay away from home and want to see those photos. It is a good idea to have your photos album stored in your personal computer. In this page, you will learn how to create your photo collection in Ms. Access 2007 by yourself. First, open Ms. Access 2007 database and create form(PhotosCollection). Then, drop 4 command buttons as shown above. You also need to drag and drop 1 image control on the form to display your photo. To store the data of your photos paths, please create a table and name it as tblphoto(ID,Photopath). After naming these controls (you may name them as used in the code below. Otherwise, it doesn't work), use the following code for cmdadd button click and Photopath textbox(a field of tblphoto table) got focus events :

Option Compare Database
Option Explicit

Private Sub cmdadd_Click()
Dim fdialog As Office.FileDialog
Dim fs As Variant
'create filedilog object
Set fdialog = Application.FileDialog(msoFileDialogFilePicker)

With fdialog
'add filters
.Filters.Add "Ms.Access Files", "*.jpg; *.bmp; *.gif", 1

If .Show Then
fs = .SelectedItems(1)
If fs <> "" Then
DoCmd.RunMacro "Macro1" 'add new record if a file was selected
Photopath.Value = fs 'add selected value to textbox
End If

End If

End With

'clear filedialog object
Set fdialog = Nothing

End Sub

Private Sub Photopath_GotFocus()
On Error Resume Next
Me.imgphoto.Picture = Me.Photopath.Value
End Sub

To move the photo forward or backward, click on forward button ( > ) or backward button (< ).

It is not necessary to write code for these control. You can create these control by wizard.

To delete the photo, click on delete button (Delete image). You also can create this button by wizard.

To add a new photo, click on Add image button that needs some codes as shown above. To make record set ready to add a new record, you need to create a macro(Macro1) with GotoRecord action.


This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.