Get field value using VBA

aanders

Registered User.
Local time
Yesterday, 19:30
Joined
Sep 5, 2013
Messages
30
Hi!

I want to get the link adress to an image in a report using VBA.
I use the following code:
PHP:
Dim strPath As String
strPath = [CurrentProject].[Path] & "\bilder\" & FirstImage
If Not Right(strPath, 7) = "bilder\" Then
    Me.huvudbild.Picture = strPath
Else
    Me.huvudbild.Picture = [CurrentProject].[Path] & "\bilder\_tom.jpg"
End If

I get the following error (translated from Swedish):
Error: 2424
The expression contains a field, a control or a property name that MS access couldnt find.
 
Hi!

I want to get the link adress to an image in a report using VBA.
I use the following code:
PHP:
Dim strPath As String
strPath = [CurrentProject].[Path] & "\bilder\" & FirstImage
If Not Right(strPath, 7) = "bilder\" Then
    Me.huvudbild.Picture = strPath
Else
    Me.huvudbild.Picture = [CurrentProject].[Path] & "\bilder\_tom.jpg"
End If
I get the following error (translated from Swedish):
Error: 2424
The expression contains a field, a control or a property name that MS access couldnt find.
It is because you are treating the function as a table and a field, by using "[]".
The correct syntax is:
Code:
Application.CurrentProject.Path
 
It is because you are treating the function as a table and a field, by using "[]".
The correct syntax is:
Code:
Application.CurrentProject.Path

No that isn't the problem. Objects, Methods and Properties work fine with bracket delimiters.

The problem is that reference to the Picture property huvubild is invalid.
It would need to be a button or subreport.

If it is a text box it won't work.

Reference to a subreportcontrol's SourceObject would be:
Code:
Me.huvudbild.Report.Picture
 
Last edited:

Users who are viewing this thread

Back
Top Bottom