当我使用此代码自定义表单的窗口小部件时,它将无法验证。如果我评论WHERE
,它就可以正常工作。
'------------------------------------------------------------
' Expirig_Click
'
'------------------------------------------------------------
Private Sub Expirig_Click()
On Error GoTo Expirig_Click_Err
DoCmd.OpenReport "Expiring", acViewPreview, "", "[DuesExpire]=[TempVars]![tempExpirationDate] And [Type]=[TempVars]![tempType]", acNormal
TempVars.Add "tempType", Combo164
TempVars.Add "tempExpirationDate", CutoffDate
DoCmd.OpenReport "Expiring", acViewReport, "", "[DuesExpire]=[TempVars]![tempExpirationDate] And [Type]=[TempVars]![tempType]", acNormal
Expirig_Click_Exit:
Exit Sub
ExpirigLabels_Click_Err:
MsgBox Error$
Resume Expirig_Click_Exit
End Sub
我已经能够解决这个问题了,工作表单(没有 init )和无效表单之间的区别是:
init :
的无效表单def __init__(..)
有效表格:
class CommentForm(forms.Form):
def __init__(self, *args, **kwargs):
self.wysiwyg = kwargs.pop('wysiwyg', False)
super(CommentForm, self).__init__()
if self.wysiwyg:
self.fields['comment_text'].widget = SummernoteWidget()
else:
self.fields['comment_text'].widget = forms.Textarea(attrs={'rows':2})
comment_text = forms.CharField()
是否存在问题以及如何解决?
谢谢!
答案 0 :(得分:4)
试试这个..可能有效
class CommentForm(forms.Form):
def __init__(self, *args, **kwargs):
try:
self.wysiwyg = kwargs['wysiwyg']
except KeyError:
self.wysiwyg = None
super(CommentForm, self).__init__(*args, **kwargs)
if self.wysiwyg:
self.fields['comment_text'].widget = SummernoteWidget()
else:
self.fields['comment_text'].widget = forms.Textarea(attrs={'rows':2})
comment_text = forms.CharField()