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

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

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

  1. Private Sub Load_HyperlinkBTN_Click()
  2. Const msoFileDialogFolderPicker As Long = 4
  3. Dim fd As Object
  4. 'Create a FileDialog object as a File Picker dialog box.
  5. Set fd = Application.FileDialog(msoFileDialogFolderPicker)
  6. 'Use a With...End With block to reference the FileDialog object.
  7. With fd
  8. 'Set the initial path to the D:\Documents\ folder.
  9. ' InitialFileName = "\\ap1\tools\db\"
  10. .Title = "Select Attachment"
  11. 'Use the Show method to display the File Picker dialog box and return the user's action.
  12. 'If the user presses the action button...
  13. If .Show = -1 Then
  14. ' DoCmd.GoToRecord , "", acNewRec
  15. Me![Charactisation results_PL Reports] = "#" & .SelectedItems(1) & "#"
  16. ' **
  17. 'If the user presses Cancel...
  18. Else
  19. End If
  20. End With
  21. 'Set the object variable to Nothing.
  22. Set fd = Nothing
  23. End Sub

答案1

得分: 1

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

  1. 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:

确定