Solved Syntax

Lampje

Member
Local time
Tomorrow, 00:27
Joined
Jul 20, 2021
Messages
37
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
 
Might resemble this:

Code:
'Application.FollowHyperlink "C:\Users\Cor\OneDrive\Afbeeldingen\Screenshots\" & Format(Now, "yyyy-mm-dd") & " (" & CStr(variable) & ").png"
 
That works perfectly, thank you very much..
 
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

Back
Top Bottom