Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
212 views
in Technique[技术] by (71.8m points)

vba - Access Database VB

I have a database built in access I need to create a button where I click it and it will open a folder related to Employee ID the problem is that the employee's folders are named as John Mich 000321 where the 000321 is john Employee Id

question from:https://stackoverflow.com/questions/65651439/access-database-vb

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try below sub

Private Sub cmdOpenEmpFolder_Click()
Dim partialName As String, partialFolder As String
Dim folderName As String
Dim folderfullPath As String

    partialName = CStr(Me.txtEmployeeID)

    partialFolder = Application.CurrentProject.Path & ""
    folderName = Dir(partialFolder & "*" & partialName, vbDirectory)
    folderfullPath = partialFolder & folderName
    Debug.Print "explorer.exe " & Chr(34) & folderfullPath & Chr(34)
    Shell "explorer.exe " & Chr(34) & folderfullPath & Chr(34), vbNormalFocus
    
End Sub

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...