dbTalk Databases Forums  

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

comp.databases.ms-access comp.databases.ms-access


Discuss How To Rotate Thru a set of Pic's - Part2 in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
carverk@hotmail.com
 
Posts: n/a

Default How To Rotate Thru a set of Pic's - Part2 - 01-05-2005 , 09:48 PM






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

Reply With Quote
  #2  
Old   
Darryl Kerkeslager
 
Posts: n/a

Default Re: How To Rotate Thru a set of Pic's - Part2 - 01-06-2005 , 06:18 PM






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"
--------------------------------------

Quote:
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:

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

Why all the otehr stuff?


Darryl Kerkeslager


<carverk (AT) hotmail (DOT) com> wrote:
Quote:
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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.