我有一个弹出窗口 - 在打开时,有(2)锁定的txt反映了辅助frm上txt框的值。同样在弹出窗口,(1)txt和(1)cbo,最终用户将键入他们的更改,然后单击确定。这将在“tblEmployeeToolAssignment”表中创建一条新记录。并且(1)cmd“OK”和(1)cmd“取消”。 OK用作保存或除外更改cmd,而取消忽略所做的更改并关闭弹出窗口frm(所有VBA)。弹出记录源是“qryToolReassignment_Grouped”。从我到目前为止所发现的是,当弹出窗口上的cmd被触发时,它没有意识到最终用户键入的txt和cbo已被更改/更改/更新/等。所以cmd什么也没做。 frm只是坐在那里。有人可以帮帮我吗?说实话,我没有写太多这段代码。我进来修理他们离开后留下的东西。
原始表格(VBA)
Private Sub Form_Open(Cancel As Integer)
Forms!frmToolReassignment_Combined!subfrmToolReassignment_Grouped.Form.cmdReassign.SetFocus
End Sub
辅助子表单(VBA)cmd以打开弹出窗口
Public Sub cmdReassign_Click()
strOpenArgs = Me.txtToolGroupID & "," & Me.txtEmployee_Name & "," & Me.txtToolCategoryQty
DoCmd.OpenForm "popfrmReassignGroupedTools", , , "ToolGroupID=" & Me.txtToolGroupID, , acWindowNormal, strOpenArgs
End Sub
Popup frm On Open
Private Sub Form_Open(Cancel As Integer)
Dim vArgs
If Not IsNull(Me.OpenArgs) Then
vArgs = Split(Me.OpenArgs, ",")
Me.txtToolCategoryQty = vArgs(2)
Me.txtToolLocation = vArgs(1)
Else
DoCmd.Close acForm, Me.Name
End If
End Sub
最后弹出窗口上的OK cmd
Private Sub cmdOK_Click()
On Error GoTo ErrHandler
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim lngEmpID As Long
Dim intQty As Integer
Dim strSQL As String
Dim strEmployee As String
Dim intToolGroupID As Integer
Dim intComma As Integer
Dim strOpenArgs As String
Dim i As Integer
strOpenArgs = Me.OpenArgs
intComma = InStr(strOpenArgs, ",")
strEmployee = Mid(strOpenArgs, intComma + 1, 99)
intToolGroupID = Left(strOpenArgs, (intComma - 1))
If IsNull(Me.cboSelEmployee) Then
GoTo ExitHere
End If
If IsNull(Me.txtQuantityAssign) Then
GoTo ExitHere
End If
lngEmpID = Me.cboSelEmployee
intQty = Me.txtQuantityAssign
Set dbs = CurrentDb
strSQL = "SELECT TOP " & intQty & " qryToolReassignment_GroupedExpanded.* " & _
"FROM qryToolReassignment_GroupedExpanded " & _
"WHERE ([ToolGroupID]=" & intToolGroupID & ") AND ([Employee Name]='" & strEmployee & "');"
Set rst = dbs.OpenRecordset(strSQL)
If rst.EOF Then
GoTo ExitHere
End If
For i = 0 To intQty - 1
With rst
.Edit
.Fields("EmployeeID") = lngEmpID
.Update
End With
rst.MoveNext
Next
DoCmd.Close acForm, Me.Name
`形式( “frmToolReassignment_Combined”)。表!subfrmToolReassignment_Grouped.Requery'
ExitHere:
On Error Resume Next
Set rst = Nothing
Set dbs = Nothing
Exit Sub
ErrHandler:
MsgBox Err.Number & ": " & Err.Description, vbExclamation
Resume ExitHere
End Sub`