我正在寻找将访问数据传递给子表单中的单词

时间:2016-07-24 16:46:51

标签: access-vba

我试图将子表单中的数据转换成单词,如果有更多的那一行数据(例如第1行= 3只猫,第2只鱼= 1只狗(我![pets_Information]![PetType]))I只能将3只猫复制到单词,我将导入旧版表格 - 文本表单字段。

我需要达到的目标是: - 在一个文本字段中有3只猫,1只狗

我可以在互联网上找到的这一点似乎很少,总是从主要表单中找到并且没有真正关于子表单/子表单

我需要设置3个表,所有人都拥有自己的keyID'

功能FillLetter()

Dim appword As Word.Application Dim doc As Word.Document Dim path As String

On Error Resume Next
Err.Clear
''''''Chaange for which computer''''''''''''''
path = "F:\Access Stuff\Job for John - PSA\Homestay Provider Information.docx"
'path = "G:\Access Stuff\Job for John - PSA\Homestay Provider Information.docx"
Set appword = GetObject(, "word.application")
If Err.Number <> 0 Then
    Set appword = New Word.Application
    appword.Visible = True
End If
    Set doc = appword.Documents.Open(path, , True)
    With doc
        .FormFields("txtClientsFName").Result = (Me.Title) & " " & (Me!ClientFirstName) & " " & (Me!ClientFamilyName) '''works
        .FormFields("txtAddress").Result = (Me!Address) '''works
        .FormFields("txtSuburb").Result = (Me!Suburb) & ", WA " & (Me.PostCode) '''works


        .FormFields("txtContactType2").Result = (Me![Contact_Information]![ContactType]) & " " & (Me![Contact_Information]![ContactDetails])

        .FormFields("txtFamily").Result = (Me![Family_Information]![Relationship]) & " " & (Me![Family_Information]![Age])

        .FormFields("txtPolice").Result = Me!LegalCert '''works
        .FormFields("txtCosts").Result = Me!CPW '''works
        .FormFields("txtMeals").Result = Me.IEMeals '''works

        .FormFields("txtPets").Result = (Me![Pets_Infomation]![PetType])

        .FormFields("txtHobbies").Result = Me!HobbiesInterests '''works
        .FormFields("txtInstitute").Result = Me.Institution '''works
        .FormFields("txtTravel").Result = Me.ToUniCollege '''works
        .FormFields("txtOther").Result = Me!OtherInformation '''works
        .Visible = True
        .Activate
    End With

Set doc = Nothing
Set appword = Nothing

结束功能

1 个答案:

答案 0 :(得分:0)

您可以使用RecordsetClone获取基础子表单数据

将此函数添加到表单中(确保常量与子表单/字段匹配):

   .FormFields("txtPets").Result = (Me![Pets_Infomation]![PetType])

然后替换此行:

   .FormFields("txtPets").Result = GetPetTypes()

此行

associative arrays