Office中国论坛/Access中国论坛

标题: 在窗体中自动重复输入的问题 [打印本页]

作者: wllight    时间: 2005-4-15 02:35
标题: 在窗体中自动重复输入的问题
Access2000里,我想在窗体中能自动输入上一条记录的内容。

在网上找了好久终于找到了,但就是不知道他说的更改窗体的oncurrent属性该怎么改。

原文是说“Change the form's OnCurrent property to read as follows”。参见http://support.microsoft.com/kb/q136127/

小弟不知在哪里更改窗体的oncurrent属性,望大侠们指教!
作者: tmtony    时间: 2005-4-23 08:56
我常用的方法:
1.如果是输入,使用ctr+' 获取上条记录同字段的值到新记录
2.在afterupdate事件中输入代码,循环需要设置上条记录默认值的字段,设置 文本框.defaultvalue="""" & 文本框.value & """"

3.使用微软的方法.

在窗体的oncurrent(成为当前)事件中加入 =AutoFillNewRecord([Forms]![Customers])

Function AutoFillNewRecord(F As Form)
         Dim RS As Recordset, C As Control
         Dim FillFields As String, FillAllFields As Integer

         On Error Resume Next

         ' Exit if not on the new record.
         If Not F.NewRecord Then Exit Function

         ' Goto the last record of the form recordset (to autofill form).
         Set RS = F.RecordsetClone
         RS.MoveLast

         ' Exit if you cannot move to the last record (no records).
         If Err <> 0 Then Exit Function

         ' Get the list of fields to autofill.
         FillFields = ";" & F![AutoFillNewRecordFields] & ";"

        ' If there is no criteria field, then set flag indicating ALL
        ' fields should be autofilled.
        FillAllFields = Err <> 0

        F.Painting = False

        ' Visit each field on the form.
        For Each C In F
        ' Fill the field if ALL fields are to be filled OR if the
        ' ...ControlSource field can be found in the FillFields list.
           If FillALLFields Or _
           InStr(FillFields, ";" & (C.Name) & ";") > 0 Then
              C = RS(C.ControlSource)
           End If
        Next

        F.Painting = True

      End Function


注意:需要在窗体上先创建一个 文本框(Text box):
名称: AutoFillNewRecordFields
可见: No
默认值: Phone;Company Name;City;State;Zip (这里修改为你需要设置取上条记录的字段名)
作者: zdczdc    时间: 2005-4-29 23:18
为什么出现对话框“类型不匹配”






作者: zdczdc    时间: 2005-5-1 17:53



应把“在窗体的oncurrent(成为当前)事件中加入 =AutoFillNewRecord([Forms]![Customers])”


改为“在窗体的oncurrent(成为当前)事件中加入 =AutoFillNewRecord([Form])”
作者: nnlm    时间: 2005-5-6 01:30
文本框.defaultvalue="""" & 文本框.value & """"

不知为什么我试了好多次都不行,请高手指点!!!!!!!!




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3