![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
On the Comboboxes "On Update" event I have the following: Private Sub StartDevice_Type_Change() Image1.Picture = LoadPicture("D:\Icons\" & cboName & ".bmp") End Sub |
|
On the Comboboxes AfterUpdate event I have the following: |
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |