By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,484 Members | 1,811 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,484 IT Pros & Developers. It's quick & easy.

How To Rotate Thru a set of Pic's - Part2

P: n/a
Hello,

Thanks for the Info. Darryl, but have decided to go a different way about this.
Here is the following update to the prob:

1. A table called "T_Photos", contains the names of the devices
(Router,switch,etc) in a field called "Photo_Desc".

2. A Combobox on the form gets it's info from the above table. So far so good
as the Combobox contains the correct data.

3. When you selsect a name from the combobox, say router, I would like it to
update the Image1.Picture Property to D:\icons\router.bmp. By default the
.bmp used is called none.bmp. All options have a relevant .bmp file with
a matching name.

On the Comboboxes "On Update" event I have the following:

Private Sub StartDevice_Type_Change()
Image1.Picture = LoadPicture("D:\Icons\" & cboName & ".bmp")
End Sub

When I change the contents of the combobox, I get the following error:

Microsoft Access can't open the file 'D:\Icons\.bmp'

So it would appear that the name chosen in the Combobox isn't being
passed correctly. I have also tried with "cmbName", which also doesn't work.

Any Ideas?

1. Create an image control, with "(none)" as the Picture property, and
Picture Type property "Linked"
2. Create a button, and place it completely over the image control. Set
it's Transparent property to "Yes"
3. Create a table with the full path of each photo:
photo_id photo_path
1 "C:\images\image1.bmp"
2 "C:\images\image12.bmp"
4. Declare form level variables:
Private photoID as Long
Private imageCount as Integer
5. In your form's Load event, load your first image from your table & store
the photo_id:
[Open recordset rs]
photoID = rs.Fields(0)
Me.imgPhoto.Picture = rs.Fields(1)
[Close recordset]
[Count records in recordset and store in imageCount] (you can use
DCount)
6. In your buttons OnClick event:
Dim cnt As Integer
[Open recordset rs]
[rs.MoveNext until rs.Fields(0) = PhotoID, incrementing cnt as you go]
If cnt = imageCount
rs.MoveFirst
Endif
photoID = rs.Fields(0)
Me.imgPhoto.Picture = rs.Fields(1)

It could be made much simpler if you name the images 1.bmp, 2.bmp, etc and
used a hardcoded path, but this allows you to have file names that are not
important to the code, a variable number of images, and variable file
locations.

Darryl Kerkeslager
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
What is the function LoadPicture()?

If imgPhoto is an image control on your form, reference the form by using
'Me'.
If cboName is an comboBox control on your form, reference the form by using
'Me'.

Set the property directly by saying:

Me.imgPhoto.Picture = "D:\Icons\" & Me.cboName & ".bmp"
--------------------------------------
On the Comboboxes "On Update" event I have the following:

Private Sub StartDevice_Type_Change()
Image1.Picture = LoadPicture("D:\Icons\" & cboName & ".bmp")
End Sub
I don't get this part ... shouldn't it just read:
On the Comboboxes AfterUpdate event I have the following:
Me.imgPhoto.Picture = "D:\Icons\" & Me.cboName & ".bmp"

Why all the otehr stuff?
Darryl Kerkeslager
<ca*****@hotmail.com> wrote: Here is the following update to the prob:

1. A table called "T_Photos", contains the names of the devices
(Router,switch,etc) in a field called "Photo_Desc".

2. A Combobox on the form gets it's info from the above table. So far so good as the Combobox contains the correct data.

3. When you selsect a name from the combobox, say router, I would like it to update the Image1.Picture Property to D:\icons\router.bmp. By default the .bmp used is called none.bmp. All options have a relevant .bmp file with a matching name.

On the Comboboxes "On Update" event I have the following:

Private Sub StartDevice_Type_Change()
Image1.Picture = LoadPicture("D:\Icons\" & cboName & ".bmp")
End Sub

When I change the contents of the combobox, I get the following error:

Microsoft Access can't open the file 'D:\Icons\.bmp'

So it would appear that the name chosen in the Combobox isn't being
passed correctly. I have also tried with "cmbName", which also doesn't work.
Any Ideas?

1. Create an image control, with "(none)" as the Picture property, and
Picture Type property "Linked"
2. Create a button, and place it completely over the image control. Set
it's Transparent property to "Yes"
3. Create a table with the full path of each photo:
photo_id photo_path
1 "C:\images\image1.bmp"
2 "C:\images\image12.bmp"
4. Declare form level variables:
Private photoID as Long
Private imageCount as Integer
5. In your form's Load event, load your first image from your table & store the photo_id:
[Open recordset rs]
photoID = rs.Fields(0)
Me.imgPhoto.Picture = rs.Fields(1)
[Close recordset]
[Count records in recordset and store in imageCount] (you can use
DCount)
6. In your buttons OnClick event:
Dim cnt As Integer
[Open recordset rs]
[rs.MoveNext until rs.Fields(0) = PhotoID, incrementing cnt as you go]
If cnt = imageCount
rs.MoveFirst
Endif
photoID = rs.Fields(0)
Me.imgPhoto.Picture = rs.Fields(1)

It could be made much simpler if you name the images 1.bmp, 2.bmp, etc and
used a hardcoded path, but this allows you to have file names that are not
important to the code, a variable number of images, and variable file
locations.

Darryl Kerkeslager

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.