0

我有一个问题,我实际上知道答案,但想把它放在那里给其他可能正在努力解决这个问题的人,因为我没有在互联网上找到答案,而是自己拼凑起来的。为了省去别人的麻烦。当您的用户每次单击不同的记录时都获得相同的记录时,在 Access 2003 中,这很可能是因为当您在设计模式下保存时,它还将服务器过滤器属性保存到它过滤到的任何记录中。然后,当您将其实时发送时,它就被卡住了。我将在下面提供这个问题的答案。

4

1 回答 1

1

这不适用于每个“事件”,因此最好的办法是将此代码放在您用来打开任何表单的任何按钮中,因为它的 ServerFilter 属性卡住或每次都复制相同的记录。再次,将此代码插入打开有问题的表单的按钮中,并在“OpenForm”函数调用您需要的表单之前执行此操作:'关闭提供的表单。以防万一它打开 DoCmd.Close acForm, "Orders" '在设计视图中重新打开提供的表单。DoCmd.OpenForm“订单”,acDesign

Public Sub Whatever()
On Error GoTo LiveError

  'Set all filters to ""
  Forms![Orders].Filter = ""
  Forms![Orders].ServerFilter = ""

  'Save the form in design view
  DoCmd.Save acForm, "Orders"

  'Close the supplied Form.
  DoCmd.Close acForm, "Orders"

  'This is where your Open Form function would go, to open whatever form you need 
  'as usual.  The only difference now is that all pre-saved filters will be gone 
  'before you apply the new filter.

  Exit Sub

LiveError:
  'This is so that when it goes live it doesn't error out since it can't open 
  'in design mode on the live server.

  'Continue opening whatever form you planned on before.  For example:

  Call OpenOrderForm(Forms![FORMNAME]![FILTERCRITERIA])
End Sub
于 2012-04-13T17:07:51.940 回答