所以这很奇怪。我确保记录源是可更新的。这是先前的工作,但是谁知道我为实现这一切所做的89097987尝试做了什么,就是这样。我有一张唱片表格。加载时细节可见= false。标题显示按钮以查找记录(弹出窗体),添加新记录(弹出窗体),然后返回主菜单。添加新记录后,用户需要单击按钮打开弹出窗体,以便用户可以选择"联系"和/或"匹配",因为关系的层次是联系 - >匹配 - >记录。我有下面的代码,执行一个存储过程,它将添加新记录并带回范围标识,所以我可以使用它来设置主记录表单上的1记录 - 记录源,当我返回它。
这一切都运行正常,除非我返回到记录表格,在这1条记录中,表格被锁定。我无法点击任何东西。访问功能区的视图显示为灰色。 当我右键单击表单的标题栏时,一切都还可以,但我不知道这意味着什么。 这是所有这一切中最奇怪的部分。为什么当我右键单击表单的标题栏时,视图会解冻,因此我可以进行布局或设计。我也可以编辑记录。
为什么我的表格冻结了?为什么我不能在表单中工作,因为我已经添加了新记录的记录来源?表单设置为允许编辑,并且字段未锁定。我无法点击表单上的选项卡控件的不同页面。我很乐意调试不同的属性,但不确定哪些可能是罪魁祸首。为什么右键单击表单的标题栏会解锁所有内容,以便再次运行?
以下是在弹出窗体中添加新记录代码:
Private Sub cmdStartNewMRecord_Click()
Dim mid As Integer
Dim cmd As New ADODB.Command
Dim midparm As New ADODB.Parameter
Dim MCID As New ADODB.Parameter
Dim frmMCSQL As String
If Nz(Me.cboChooseContact.Column(0), 0) = 0 Then
MsgBox "No Contact has been selected. Records must be assigned to a valid Contact and Match.", vbCritical, "Must Choose a Contact and Match to Continue."
ElseIf Nz(Me.cboChooseMatch.Column(0), 0) = 0 Then
MsgBox "No Contact has been selected. Records must be assigned to a valid Contact and Match.", vbCritical, "Must Choose a Contact and Match to Continue."
Else
mid = Nz(Me.cboChooseMatch.Column(0), 0)
With cmd
.CommandText = "sp_AddNewMatchRecord"
.CommandType = adCmdStoredProc
.ActiveConnection = "DRIVER={SQL Server};SERVER=blahservername;DATABASE=blahdatabasename"
Set midparm = .CreateParameter("@mid", adVarChar, adParamInput, 30, mid)
.Parameters.Append midparm
Set MCID = .CreateParameter("@NEWID", adCurrency, adParamOutput)
.Parameters.Append MCID
.Execute Options:=adExecuteNoRecords
Set .ActiveConnection = Nothing
Set midparm = Nothing
End With
Debug.Print MCID
End If
frmMCSQL = "SELECT * FROM tblMRecords WHERE ID = " & MCID
Forms!frmMRecords.RecordSource = frmMCSQL
Forms!frmMRecords.Visible = True
Forms!frmMRecords.Detail.Visible = True
Forms!frmMRecords.Refresh
Call ShowRequirements(Nz(MCID, 0))
Set MCID = Nothing
Set cmd = Nothing
DoCmd.Close acForm, "frmMRecords_AddNewRecord", acSaveNo
End Sub
这是主记录表格中的所有代码(不是很多):
Option Compare Database
Option Explicit
Private Sub Form_Load()
Me.Detail.Visible = False
End Sub
Private Sub cmdNew_Click()
DoCmd.OpenForm "frmMRecords_AddNewRecord"
Me.Form.Visible = False
End Sub
Private Sub cmdFindMRecord_Click()
DoCmd.OpenForm "frmMRecords_FindRecords"
Me.Form.Visible = False
End Sub
Private Sub cmdQContacts_Click()
MsgBox "Contacts listed are only those entered for this Contact." & vbCrLf & _
"Please add Contacts in Contacts Section, " & vbCrLf & _
"and then assign them to a type of contact here within a Record.", vbQuestion, "Assign Contacts to Types of Contacts Within Records"
End Sub
Private Sub cmdMainMenu_Click()
Forms!frmMain.Visible = True
DoCmd.Close acForm, "frmMRecords", acSaveYes
End Sub
这些是主要记录形式属性的打印屏幕:
http://files.engineering.com/getfile.aspx?folder=fd94084a-ec0d-4140-912e-4e933018d82e&file=MainRecordFormatProperties.jpg
http://files.engineering.com/getfile.aspx?folder=2bcd17ed-8e73-4f8f-b82c-5e28b528370c&file=MainRecordOtherProperties.jpg
http://files.engineering.com/getfile.aspx?folder=66e7924e-a312-4b64-a177-34a6d5156bc7&file=MainRecordDataProperties.jpg
非常感谢任何帮助!
答案 0 :(得分:0)
我想出来了。添加新记录表单设置为弹出是和模态是。即使我关闭了那个表单,它也没有正确地释放控制权。由于我没有任何其他可见的表格,我把它们转为否,现在它有效!好极了! 3个小时的睡眠,我想通了!