Good morning:
I need some assistance with, potentially, cleaning up/trimming a string value (i.e., "strPath_2").
Recap (username):
- DB includes a "username" import function.
- There never has been any issues displaying it when using "username" in, e.g., a form's text field.
Recap (what I'm trying to achieve):
- I need to create an export routine that outputs, e.g., a spreadsheet on the user's name desktop (or any other designated path)
- To make it dynamic, I'd like to create a concatenated file path string
Issue:
- Per VBA code below, the username ("strPath_2") returns a bunch of block/rectangle characters
- Thus, when concatenating all 3 string elements (i.e., "strPath_Concat = strPath_1 & strPath_2 & strPath_3"), the third element ("strPath_3") is NOT included in the concatenated string ("strPath_Concat").
Goal:
- Output, e.g., "strPath_Concat" = "C:\Users\jsmith\CompanyName\Mainfolder\Subfolder" .... where "jsmith" is NOT a constant but being dynamically read into
Please see attached PNG which illustrates both the 'hover over' values as well as 'message boxes'. If indeed strPath_2's block/rectangle characters cause strPath_3 NOT to be included in the concatenated string, what is the solution for, e.g., trimming/cleaning up "strPath_2"?
Code:
Option Compare Database
Option Explicit
Private Sub Form_Load()
'Checks current network login ID is
Me!txtNetworkID = fOSUserName()
Me!txt_username = Me!txtNetworkID
End Sub
Private Sub Listbox1_AfterUpdate()
Dim strPath_1 As String
Dim strPath_2 As String
Dim strPath_3 As String
Dim strPath_Concat As String
strPath_1 = "C:\Users\"
strPath_2 = Me!txtNetworkID
strPath_3 = "\CompanyName\Mainfolder\Subfolder"
strPath_Concat = strPath_1 & strPath_2 & strPath_3
MsgBox "Msg Box #1: " & strPath_1
MsgBox "Msg Box #2: " & strPath_2
MsgBox "Msg Box #3: " & strPath_3
MsgBox "Msg Box Concat: " & strPath_Concat
'... More functionality
'...
'...
End Sub