我在MS Access 2010中有一个mainform。它有两个子表单,它们链接在一起。其中一个潜艇是“单一形式”,另一个是“数据表视图”。在上部Sub,用户可以看到记录的详细信息,在下面的子部分中选择。它工作正常。
我想从其他Access-App打开此Access-App,打开mainform并转到特定记录。这是代码:
Dim appAccess As Access.Application
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase "C:\xxx\xxx\Desktop\MyAccess.accdb"
appAccess.DoCmd.OpenForm "subGridView", , , "[Number_X] = '" & Me.number_for_X.Value & "'"
它可以工作,但我打开子窗体,位于MAIN下面。我想我需要这样的东西:
Dim appAccess As Access.Application
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase "C:\xxx\xxx\Desktop\MyAccess.accdb"
appAccess.DoCmd.OpenForm "MAIN"
appAccess.DoCmd.GoToRecord acDataForm, "subGridView", acGoTo, 37
37只是一个测试参数...
或类似的东西:
Dim appAccess As Access.Application
Dim rNr As String
Set appAccess = CreateObject("Access.Application")
rNr = Me.number_for_X.Value
appAccess.OpenCurrentDatabase "C:\xxx\xxx\Desktop\MyAccess.accdb"
appAccess.DoCmd.OpenForm "MAIN"
Forms!subGridView.Recordset.FindFirst "[Retoure_Nummer] = '" & rNr
Set appAccess = Nothing
请给我一些提示: - )
Greetz Vegeta_77
答案 0 :(得分:0)
尝试这样的事情:
Forms!MAIN!subGridView.Form.Recordset.FindFirst "[Retoure_Nummer] = '" & rNr & "'"
其中subGridView
不是子表单的独立名称,而是主表单中子表单控件的名称(通常是相同的但不一定)。