MS Access 2007:“代码打开”后无法更改字段一种形式

发布于 2024-10-01 09:57:39 字数 1299 浏览 0 评论 0原文

我正在努力在 MS Access 2007 中创建多种表单。 我完成了以下任务:我有患者表单,我可以在其中创建/编辑患者记录。当按下保存按钮时,我将打开另一个表单,该表单的任务是输入属于两个表的信息。该表单上的表处于 1-1 关系,并且都使用外键(来自患者表的 PatiendID)。

我设法让一切正常工作 - 当我更新/保存新患者时,我打开了一个新表格,其中包含要输入的一堆实验室结果。一些结果属于一个表,其他结果属于另一表。 PatientID 字段(在第二个表单上也可见)已按其应有的方式设置。但是,当我尝试在该表单上的任何字段中输入任何值时 - 我在状态栏上收到以下警告:“此记录集不可更新”。 我认为这与我实际上在一个表单上打开了两个表有关,但我可能是非常错误的。

这是我用来打开第二种形式的代码:

Private Sub save_Click()
  Dim m_query As String
  m_query = "INSERT INTO labresults (patientID) VALUES (" & Me.ID & ")"
  If Me.Dirty = True Then
     Me.Dirty = False
  End If
  If DCount("patientID", "labresults", "patientID = " & Me.ID) = 0 Then
      CurrentDb.Execute m_query, dbFailOnError
  End If
  m_query = "INSERT INTO par14MO (patientID) VALUES (" & Me.ID & ")"
  If DCount("patientID", "par14MO", "patientID = " & Me.ID) = 0 Then
      CurrentDb.Execute m_query, dbFailOnError
  End If

  If CurrentProject.AllForms("labresults").IsLoaded = True Then
      Forms![labresults]![patientID] = Me.ID
      Forms![par14MO]![patientID] = Me.ID
  Else
      DoCmd.OpenForm "labresults", acNormal, , "idPAcijenta = " & Me.ID, acFormEdit, acWindowNormal, Me.ID
  End If

End Sub

有什么想法吗???

非常感谢! 我仍在谷歌搜索并尝试...如果我设法解决问题,我将发布我的发现!

I'm fighting with creation of several forms in MS Access 2007.
I accomplished the following: I have patients form, where I can create / edit patient records. When save button is pressed, I'm opening another form, that has a task of entering information that belong to 2 tables. Tables on that form are in 1-1 relationship, and both use foreign key (patiendID from patients table).

I managed to make everything work fine - when I update / save new patient, I have a new form opened with a bunch of lab results to be entered. Some of the results belong to one table, and other to another table. patientID field, that is also visible on that 2nd form is set as it should be. However, when I try to enter ANY value in ANY field on that form - I get following warning on the status bar: "This Recordset is not updateable".
I think that this has smt to do with the fact that I actually opened 2 tables on a single form, but I might be very wrong.

Here is the code I use to open 2nd form:

Private Sub save_Click()
  Dim m_query As String
  m_query = "INSERT INTO labresults (patientID) VALUES (" & Me.ID & ")"
  If Me.Dirty = True Then
     Me.Dirty = False
  End If
  If DCount("patientID", "labresults", "patientID = " & Me.ID) = 0 Then
      CurrentDb.Execute m_query, dbFailOnError
  End If
  m_query = "INSERT INTO par14MO (patientID) VALUES (" & Me.ID & ")"
  If DCount("patientID", "par14MO", "patientID = " & Me.ID) = 0 Then
      CurrentDb.Execute m_query, dbFailOnError
  End If

  If CurrentProject.AllForms("labresults").IsLoaded = True Then
      Forms![labresults]![patientID] = Me.ID
      Forms![par14MO]![patientID] = Me.ID
  Else
      DoCmd.OpenForm "labresults", acNormal, , "idPAcijenta = " & Me.ID, acFormEdit, acWindowNormal, Me.ID
  End If

End Sub

Any ideas what's going on???

Thx a bunch!
I'm still googling and trying... I'll post my findings if I manage to sort things out!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜唯美灬不弃 2024-10-08 09:57:39

事实证明这确实是做不到的:)。结束这个,并假设这是一个答案。

编辑:有人向我建议我最后的陈述是不正确的。不过,我“手动”解决了问题,现在一切正常了。我将继续并接受这个答案,以便将我的回答保持在良好的水平。

Turns out that this really cannot be done :). Closing this one, and assuming this is an answer.

Edit: It was suggested to me that my last statement is not true. However, I solved things "manually", and everything is ok now. I'll go on and accept this answer in order to keep my response at a good level.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文