我在MainForm(“主菜单”)上有一个SubForm(“Main Menu SubForm”)...我想在SubForm上选择一行,然后将相应的行拉到另一个表格进行编辑。
我有以下代码,但似乎没有按照我的预期行事:
Private Sub Form_Activate()
Me.Requery
If IsLoaded("Main Menu") Then
If Forms![Main Menu]![Main Menu SubForm].Form.RecordsetClone.RecordCount > 0 Then
DoCmd.GoToControl "txtWOrderID"
DoCmd.FindRecord Forms![Main Menu]![Main Menu SubForm].Form![WOrderID]
End If
End If
End Sub
如果需要,我已附加了一个指向我的数据库的链接以供参考: Access Invoice System
答案 0 :(得分:0)
我会做类似的事(这是空气码,所以需要调整):
forms!WOrderID.RecordSource = "Select * from MyTable where WOrderID = " & me.txtWOrderID & ""
Forms!wOrderID.Refresh
答案 1 :(得分:0)
我从主表单中完成了这项工作:
Private Sub btnViewWorkOrder_Click()
DoCmd.OpenForm "Work Order", acNormal, , "[WOrderID] = '" & Forms![Main Menu]![txtWOrderID] & "'", acFormEdit, acDialog
End Sub