Dim FtNY As String
Dim ayf As WinForm.RadioButton = e.form.Controls("按月份")
Dim arq As WinForm.RadioButton = e.form.Controls("按日期")
Dim NY1, NY2 As Integer
Dim NY3 As String
NY1 = e.form.Controls("QZNY1").value
NY2 = e.form.Controls("QZNY2").value
NY3 = e.form.Controls("PCNY").value
If ayf.Checked = True Then
If ny3.Length > 0 Then
FtNY = "年月 >= " & NY1 & " and 年月 <= " & NY2 & " and 年月 Not in (" & ny3 & ")"
ElseIf ny3 = "" Then
FtNY = "年月 >= " & NY1 & " and 年月 <= " & NY2 & ""
End If
ElseIf arq.Checked = True Then
FtNY = "日期 >= '" & rq1 & "' and 日期 <= '" & rq2 & "'"
End If
msgbox(FtNY)
上面绿色部分执行没问题,黄色部分提示以下错误,把条件去掉单单执行FtNY = "年月 >= " & NY1 & " and 年月 <= " & NY2 & ""也是没有问题,有点晕
此主题相关图片如下:微信图片_20241028210500.png