Im attempting to replace all my path constants in VBA with an administration table in my datatbase so users can change the location of folders and files without having to edit vba code.
the code is as follows
Private Sub Command8_Click()
Debug.Print DLookup("fsFileLink", "tblFileSystem", "fsFileName= 'TEMPLATES'")
MsgBox = DLookup("fsFileLink", "tblFileSystem", "fsFileName= 'TEMPLATES'")
End Sub
debug.print returns
C:\Users\... \templates\
but the msgbox returns the error "left must be variant or object". How can I get my dlookup value as a string that I can display and edit in a text box?
Thank You
MsgBox =
is not a correct syntax – user2140173strResult = InputBox("Your title", DLookup("fsFileLink", "tblFileSystem", "fsFileName= 'TEMPLATES'"))
, which should show you the looked-up path as a default value but let you edit it on screen. – pteranodoncode'strResult = InputBox("Your title", default:=DLookup("fsFileLink", "tblFileSystem", "fsFileName= 'TEMPLATES'"))
works – Ian Jackson