All this code is doing is putting the "filename" (actually, the full path
with filename) in a control named [txtFileName] on a form named
[frmNewDatafile]. It does it by allowing the user to select the file name
through the file browser option.
Just hardcode in the path and use it:
[frmNewDatafile]![txtFileName] = "C:\DataTables\FiscalYear.mdb"
or you could use a variable in place of [frmNewDatafile]![txtFileName]. All
the rest of this code is needed in order to open the file browser dialog box
and to read the info about the selected file.
--
Hoping that this is helpful...
Ken Snell
<MS ACCESS MVP>
Quote:
> I found the code below on The Access Web for Refreshing
> Links. I need to modify it to tell it specifically what
> database to refresh, not to browse for it. How would I
> modify the code to do that? I.E., I want to hard code a
> name and path like "C:\DataTables\FiscalYear.mdb"
> Public Function Browse()
> ' Prompts user for back-end database file name.
> On Error GoTo Err_Browse
> Dim strFilename As String
> Dim oDialog As Object
> Set oDialog = [forms]![frmNewDatafile]!
> XDialog.Object
> With oDialog ' Ask for new file location.
> .DialogTitle = "Please Select New Data File"
> .Filter = "Access Database
> (*.mdb;*.mda;*.mde;*.mdw)|" & _
> "*.mdb; *.mda; *.mde; *.mdw|All(*.*)|*.*"
> .FilterIndex = 1
> .ShowOpen
> ' If user responded, put selection into text box
> on form.
> If Len(.FileName) > 0 Then _
> [forms]![frmNewDatafile]![txtFileName] = .FileName
> End With
> Thank you.