谢谢wan_shan的指教!做了一些小修改以后,大功告成!
Private Sub PMP_Click()
dim strwhere as string
If Me.PMP = True Then
If MsgBox("提问:是否要进入设备维修保养?", vbYesNo, "提示") = vbYes Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
strWhere = "[识别号] IN ('" & Me.txtid & "')"
DoCmd.OpenForm "设备维修保养"
Forms!设备维修保养.Filter = strWhere
Forms!设备维修保养.FilterOn = True
End If
End If
End Sub
还有一种更简单的方法,由hi-wzj提供,我稍微修改一下.
Private Sub PMP_Click()
If Me.PMP = True Then
If MsgBox("提问:是否要进入设备维修保养?", vbYesNo, "提示") = vbYes Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "设备维修保养", , , "[识别号]='" & Me.识别号 & "'"
End If
End If
End Sub
但是现在又有新问题,因为DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70这条语句,我在保存窗体前要做是否保存的判断,当否定时,会出现
相关代码如下:
Private Sub closeform_Click()
On Error GoTo Err_closeform_Click
If allowSave = True Then
If MsgBox("当前数据已经被修改,是否保存?", vbYesNo + vbQuestion, "请选择...") = vbYes Then
Else
Me.undo
End If
End If
DoCmd.Close
Exit_closeform_Click:
Exit Sub
Err_closeform_Click:
MsgBox Err.Description
Resume Exit_closeform_Click
End Sub
Private Sub PMP_Click()
If Me.PMP = True Then
If MsgBox("提问:是否要进入设备维修保养?", vbYesNo, "提示") = vbYes Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "设备维修保养", , , "[识别号]='" & Me.识别号 & "'"
End If
End If
End Sub
Private Sub cmdsave_Click()
On Error GoTo Err_cmdsave_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_cmdsave_Click:
Exit Sub
Err_cmdsave_Click:
MsgBox Err.Description
Resume Exit_cmdsave_Click
End Sub
[此贴子已经被作者于2005-4-11 14:31:50编辑过] |