Solved Syntax (1 Viewer)

Lampje

Member
Local time
Today, 03:03
Joined
Jul 20, 2021
Messages
31
Dear Forum,

the Application.FollowHyperlink works well, however I make several png images per day. What should the syntax be like if I want to use a variable for (20).


Code:
Option Compare Database
Option Explicit
Private S As String
Private X As Integer


Private Sub Knop6_Click()
X = 1
S = CStr(X)


'Application.FollowHyperlink "C:\Users\Cor\OneDrive\Afbeeldingen\Screenshots\" & Format(Now, "yyyy-mm-dd") & " (20).png"

End Sub
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 20:03
Joined
Feb 28, 2001
Messages
27,358
Might resemble this:

Code:
'Application.FollowHyperlink "C:\Users\Cor\OneDrive\Afbeeldingen\Screenshots\" & Format(Now, "yyyy-mm-dd") & " (" & CStr(variable) & ").png"
 

Lampje

Member
Local time
Today, 03:03
Joined
Jul 20, 2021
Messages
31
That works perfectly, thank you very much..
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 02:03
Joined
Sep 12, 2006
Messages
15,723
In passing, the syntax might well have worked without the cstr.
Access VBA is pretty forgiving about stuff like that.

it's also easy to test the string looks right while you are developing it.

eg without the cstr()
msgbox "C:\Users\Cor\OneDrive\Afbeeldingen\Screenshots\" & Format(Now, "yyyy-mm-dd") & " (" & variable & ").png"

you could also include a dir() test in case the file does not exist, as it might be cleaner than the message application.followhyperlink would give you. There's a lot of choice.
 

Users who are viewing this thread

Top Bottom