MS Access – 使用msoFileDialogFolderPicker保存链接到另一个表,而不是使用”me”。

huangapple go评论79阅读模式
英文:

MS Access - Saving link to another table with msoFileDialogFolderPicker , other then "me"

问题

我试图使用msoFileDialogFolderPicker保存链接位置。我想将链接保存在另一个名为"Characterization results"的表中的名为"PL Reports"的字段内。

我如何引用另一个表中的字段,类似于:PL Reports_Characterization results?

谢谢

英文:

I'm trying to save a link location using msoFileDialogFolderPicker. I want to save the link inside another table with the name of "Characterization results" to field named "PL Reports".

How i can refer to a field in another table like: PL Reports_Characterization results ?

Thanks

Private Sub Load_HyperlinkBTN_Click()

   Const msoFileDialogFolderPicker As Long = 4

   Dim fd As Object
'Create a FileDialog object as a File Picker dialog box.
   Set fd = Application.FileDialog(msoFileDialogFolderPicker)
'Use a With...End With block to reference the FileDialog object.
   With fd
'Set the initial path to the D:\Documents\ folder.
  ' InitialFileName = "\\ap1\tools\db\"
   .Title = "Select Attachment"
'Use the Show method to display the File Picker dialog box and return the user's action.
'If the user presses the action button...
   If .Show = -1 Then
'   DoCmd.GoToRecord , "", acNewRec
    Me![Charactisation results_PL Reports] = "#" & .SelectedItems(1) & "#"

'  **

'If the user presses Cancel...
   Else
   End If
 End With

'Set the object variable to Nothing.
   Set fd = Nothing

End Sub

答案1

得分: 1

这将在表格“Characterization results”中插入一条新记录,并将值.SelectedItems(1)保存到字段“PL Reports”中:

CurrentDb.Execute "INSERT INTO [Characterization results] ([PL Reports]) VALUES ('" & .SelectedItems(1) & "');", dbFailOnError

附注:正如@June7所指出的,您应该尽量避免在名称中使用空格。

英文:

This should insert a new record in table Characterization results and save the value .SelectedItems(1) in the field PL Reports:

CurrentDb.Execute "INSERT INTO [Characterization results] ([PL Reports]) VALUES ('" & .SelectedItems(1) & "');", dbFailOnError

P.S. You should really avoid using space in names as @June7 stated.

huangapple
  • 本文由 发表于 2023年7月31日 21:15:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76804021.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定