Browse option and sving folder path

P

PsyberFox

Hi there,

I want a user to select a path from a pop-up and then this folder location
should be saved in a table. Can someone please assist with the last part as
I'm not sure how to update a record from information supplied via a form.

Here is the code thusfar but the last option obviously doesn't work as it
should:

Private Sub cmd_FileLocation_Click()

On Error Resume Next

Dim f As FileDialog
Set f = Application.FileDialog(msoFileDialogFolderPicker)
f.Show
MsgBox ("You have selected: ") & f.SelectedItems(1)

DoCmd.OpenTable "tbl_XSetup_files"
[tbl_XSetup_Files].[FileLocation].Value = f.SelectedItems(1)

End Sub

Thank you kindly!
W
 
R

RonaldoOneNil

Private Sub cmd_FileLocation_Click()

On Error Resume Next

Dim f As FileDialog
Set f = Application.FileDialog(msoFileDialogFolderPicker)
f.Show
MsgBox ("You have selected: ") & f.SelectedItems(1)

DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tbl_XSetup_files SET FileLocation = '" &
f.SelectedItems(1) & "'"
DoCmd.SetWarnings True

End Sub
 
P

PsyberFox

THANK YOU BOTH!!!

RonaldoOneNil said:
Private Sub cmd_FileLocation_Click()

On Error Resume Next

Dim f As FileDialog
Set f = Application.FileDialog(msoFileDialogFolderPicker)
f.Show
MsgBox ("You have selected: ") & f.SelectedItems(1)

DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tbl_XSetup_files SET FileLocation = '" &
f.SelectedItems(1) & "'"
DoCmd.SetWarnings True

End Sub

PsyberFox said:
Hi there,

I want a user to select a path from a pop-up and then this folder location
should be saved in a table. Can someone please assist with the last part as
I'm not sure how to update a record from information supplied via a form.

Here is the code thusfar but the last option obviously doesn't work as it
should:

Private Sub cmd_FileLocation_Click()

On Error Resume Next

Dim f As FileDialog
Set f = Application.FileDialog(msoFileDialogFolderPicker)
f.Show
MsgBox ("You have selected: ") & f.SelectedItems(1)

DoCmd.OpenTable "tbl_XSetup_files"
[tbl_XSetup_Files].[FileLocation].Value = f.SelectedItems(1)

End Sub

Thank you kindly!
W
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top