lodmark
Member
- Local time
- Today, 05:47
- Joined
- Jul 24, 2020
- Messages
- 232
Hey!
I have created a new database for my vinyl collection, following tips I received from this forum.
So far, things are going well.
I have some code from the old database, that works with that database, I thought I would recycle that code.
It's about choosing a picture for the disc.
I have copied the code and renamed controls and database objects.
But I get an error that I do not understand, the error message says "Run-Time error '438': Object does not support this property or method".
As I said, the code works in the old database.
What is wrong.
This is the code for the "PicturePicker"
And this is for the click event that belongs to the button that selects the picture.
This is where the error occurs, in the line:
Me.AlbumPicture = strPicture
As usual, I am grateful for all the tips.
The database is also attached, there is only rubbish in it so change as you want.
Leif
I have created a new database for my vinyl collection, following tips I received from this forum.
So far, things are going well.
I have some code from the old database, that works with that database, I thought I would recycle that code.
It's about choosing a picture for the disc.
I have copied the code and renamed controls and database objects.
But I get an error that I do not understand, the error message says "Run-Time error '438': Object does not support this property or method".
As I said, the code works in the old database.
What is wrong.
This is the code for the "PicturePicker"
Code:
Public Function PicturePicker() As String
Dim fd As Office.FileDialog
Dim FileName As String
'Set fd = Application.FileDialog(msoFileDialogFolderPicker)
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.title = "Select a Picture"
.Filters.Clear
.Filters.Add "Pictures", "*.ani;*.bmp;*.gif;*.ico;*.jpe;*.jpeg;*.jpg;*.pcx;*.png;*.psd;*.tga;*.tif;*.tiff;*.webp;*.wmf, 1"
.Filters.Add "All files", "*.*", 2
.AllowMultiSelect = False
If .Show = -1 Then
PicturePicker = (.SelectedItems(1))
End If
'Set variable "filename" equal to path of file selected:
FileName = fd.SelectedItems(1)
'You can now use the filename for the file selected in your code:
MsgBox FileName
End With
Set fd = Nothing
End Function
And this is for the click event that belongs to the button that selects the picture.
Code:
Private Sub cmdUpdateAlbumPicture_Click()
Dim strPicture As String
Dim ID As Long
strPicture = PicturePicker
'MsgBox strPicture
If Len(strPicture) > 0 Then
Me.AlbumPicture = strPicture
End If
End Sub
This is where the error occurs, in the line:
Me.AlbumPicture = strPicture
As usual, I am grateful for all the tips.
The database is also attached, there is only rubbish in it so change as you want.
Leif