Shortcut for menu's

steve99jones

New member
Local time
Today, 04:11
Joined
Jan 21, 2005
Messages
7
Hi

Can anyone tell me how to create a shortcut button or macro that will simplify the following procedure when working with an Access form (version 2000):

Insert > Object > From File > Bitmap Image > OK > Edit > Paste From > ....

I use this to insert photo's into a database, but with large databases it gets very tiresome!

Thanks for nay help.

Steve
:confused:
 
I'm not sure what u're really trying to do: "... Edit > Paste From >" ?? And how do u want to automate the picking of specific photos?

For inserting photos in your DB you might consider using a button which opens a fileDialog.

Sub btnAddPic_Click()

Dim pic As String
Dim result As Integer
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Image"
.Filters.Add "All Archives", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Gif", "*.gif" 'add other extensions if you like
.FilterIndex = 2 'this will preselect "JPEGs", "*.jpg" when you open the dialog
.AllowMultiSelect = False
.InitialFileName = CurrentProject.Path
result = .Show
If (result <> 0) Then
pic = Trim(.SelectedItems.Item(1))
Me![ImageFrame].Picture = pic
End If
End With
End Sub

You need to place an Image control (ImageFrame) on the form if u want to view the image on the form. Also make sure you put a reference to MS Office 11 Object library (11 = access 2003, yours is probably 10).

Note that this will link to the files on your HD, not embed them in the DB

Good luck
Jaime
 
Hi Jamie

Thanks for the reply and apologies for the delay in responding!

The "... Edit > Paste From >" bit is part of the menu options that you get when you select:

"Insert > Object > From File > Bitmap Image > OK >" from the access pull down menu's. What effectively happens is that it opens up MS Paintbrush to enable you to create a picture in the image frame.

I will have a look at the code you have posted, but I do not have any experience of writing code as I tend to use macros or the in-built wizards which I can cope with a little more easily!

If you do have any other suggestions I would be grateful.

Many thanks

kind regards

Steve
 
The code I gave u is simply for selecting image files on your computer and insert them in your form. Just place an Image frame on your form (Toolbox > image, choose whatever image, then delete the path afterwards in the properties of the frame) and name it IM1 (or whatever u like, but then u have to change all occurences of IM1 in the code too). Then place a button and name it btnAddPic, and activate it's click event for procedure code.

U might add another button, to remove an image: btnRemPic and paste this code in your form's module:

sub btnRemPic_Click()
Me.IM1.Picture = ""
end sub

You should create and format your pictures outside of access, name them systematically and place them in a folder. After that u just click your buttons on the form to insert or remove them. Take a look in the sample DB in access, Northwind.MDB. Open the employees form and take a look at the code behind. This sample code from northwind.mdb seems a bit buggy though (on my computer at least) but it should give u an idea.

For the rest I suggest u to go after some books and tuts and start studying, for Access is very simple for simple tasks but for more elaborate funcionality u should dive into VBA, macros won't do. If u already know your way with macros u can convert your existing macros automatically to VBA (Tools > Macros >Convert Macros to VBA). This will help you learn how VBA works.

Regards,
Jaime
 

Users who are viewing this thread

Back
Top Bottom