I want to link to tables in a database. If I state which database WITHIN THE CODE, as in
Private Sub Command0_Click()
DoCmd.TransferDatabase acLink, "Microsoft Access", "T:\www.bemrosebooth.com\OnLine_Marketing\Link Building\Link Survey databases\SmartCards.mdb", acTable, "tblDeleteMe", False
End Sub
it works well.
BUT I would like to use an InputBox to name the database I want to link. This code is almost the same as above,
Private Sub Command1_Click()
Dim stDocName As String
Dim strfilename As String
strfilename = InputBox("What is the name of the database you'd like to link to?")
DoCmd.TransferDatabase acLink, "Microsoft Access", "T:\www.bemrosebooth.com\OnLine_Marketing\Link Building\Link Survey databases\" & "strfilename" & ".mdb", acTable, "tblDeleteMe"
End Sub
Yet it won't oblige. "Can't find the database file," a message box says. And it gives this path, 'T:\www.bemrosebooth.com\OnLine_Marketing\Link Building\Link Survey databases\strfilename.mdb.
So somehow, Access misunderstands the InputBox arrangement. Be very pleased if anyone can spot my mistake.
Cheers
Private Sub Command0_Click()
DoCmd.TransferDatabase acLink, "Microsoft Access", "T:\www.bemrosebooth.com\OnLine_Marketing\Link Building\Link Survey databases\SmartCards.mdb", acTable, "tblDeleteMe", False
End Sub
it works well.
BUT I would like to use an InputBox to name the database I want to link. This code is almost the same as above,
Private Sub Command1_Click()
Dim stDocName As String
Dim strfilename As String
strfilename = InputBox("What is the name of the database you'd like to link to?")
DoCmd.TransferDatabase acLink, "Microsoft Access", "T:\www.bemrosebooth.com\OnLine_Marketing\Link Building\Link Survey databases\" & "strfilename" & ".mdb", acTable, "tblDeleteMe"
End Sub
Yet it won't oblige. "Can't find the database file," a message box says. And it gives this path, 'T:\www.bemrosebooth.com\OnLine_Marketing\Link Building\Link Survey databases\strfilename.mdb.
So somehow, Access misunderstands the InputBox arrangement. Be very pleased if anyone can spot my mistake.
Cheers