方法1
Private Function shipSailAccount_guozhang1101() As Boolean
On Error GoTo errhandle
shipSailAccount_guozhang1101 = True '默认为true'''''''省略程序
Exit Function
errhandle:
shipSailAccount_guozhang1101 = False
Exit Function
End Function
共4个方法,类似于方法1窗体事情
Private Sub Form_Load()
''新添加
Dim blnIsFalse As Boolean
If shipSailAccount_guozhang1101() = False Then
ssql = "insert into 过帐状态表(过帐时间,开船时间,状态) values ('" & DtToday & "','" & DepartDate & "','0') "
cn.Execute ssql, rdExecDirect
Exit Sub
ElseIf shipSailAccount_guozhang1102() = False Then
ssql = "insert into 过帐状态表(过帐时间,开船时间,状态) values ('" & DtToday & "','" & DepartDate & "','0') "
cn.Execute ssql, rdExecDirect
Exit Sub
ElseIf shipSailAccount_guozhang1103() = False Then
ssql = "insert into 过帐状态表(过帐时间,开船时间,状态) values ('" & DtToday & "','" & DepartDate & "','0') "
cn.Execute ssql, rdExecDirect
Exit Sub
ElseIf shipSailAccount_guozhang1104() = False Then
ssql = "insert into 过帐状态表(过帐时间,开船时间,状态) values ('" & DtToday & "','" & DepartDate & "','0') " cn.Execute ssql, rdExecDirect
Exit Sub
Else
ssql = "insert into 过帐状态表(过帐时间,开船时间,状态) values ('" & DtToday & "','" & DepartDate & "','1') "
cn.Execute ssql, rdExecDirect
End If
Exit Sub
End Sub
我的程序想实现,当4个方法中只要有错误,进行错误捕捉,写入状态0,只有全部都正确,才写入状态1,
我已经设了错误捕捉,可是为什么当程序初始化时候,即自动作业时候,突然断电(程序强行退出)时候,我的状态表中没写入状态0呢?请问下如何解决呢?谢谢
比如我查询到的开船时间是5月1日 5月2日 5月3日 5月6日 5月8日
而我的时间段是5月1日-9日
我任何得到5月4日 5月5日 5月7日 5月9日(DepartDate)
得到这些时间后,提示不成功,并把记录
ssql = "insert into 过帐状态表(过帐时间,开船时间,状态) values ('" & now & "','" & DepartDate & "','0') "
cn.Execute ssql, rdExecDirect
如我下面时间是状态为0的时候做出提示,如果是不包含在状态表中的又如何提示呢?谢谢Dim msql As String
Dim strmsg As String
msql = "select 过帐状态表.开船时间 as 开船时间 from 过帐状态表 where 状态 = '0' and 开船时间 between '" & starDT & "' and '" & endDT & "' group by 开船时间"
Set rst = cn.OpenResultset(msql, rdOpenStatic, rdConcurReadOnly)
If Not rst.EOF Then
While Not rst.EOF
strmsg = strmsg & Format(rst!开船时间, "yyyy年mm月dd日") & ","
rst.MoveNext
Wend
rst.Close
MsgBox strmsg, 48, "以下日期自动过帐不成功,请进行手动过帐,再结算"
Exit Sub
End If
比如:我查询到的表中状态为0的开船时间是5月1日 5月6日 5月8日 ,状态为1的开船时间是5月2日,5月3日
而我的时间段是5月1日-9日
在时间段里有但表中没有的时间是5月4日 5月5日 5月7日 5月9日,我下面代码得到的strmsg是状态为0的开船时间
是5月1日 5月6日 5月8日,而我想改得到的是strmsg是5月1日 5月6日 5月8日 5月4日 5月5日 5月7日 5月9日
既状态为0的开船时间和在时间段里但不在表里的时间,请问如何实现啊?谢谢Dim msql As String
Dim strmsg As String
msql = "select 过帐状态表.开船时间 as 开船时间 from 过帐状态表 where 状态 = '0' and 开船时间 between '" & starDT & "' and '" & endDT & "' group by 开船时间"
Set rst = cn.OpenResultset(msql, rdOpenStatic, rdConcurReadOnly)
If Not rst.EOF Then
While Not rst.EOF
strmsg = strmsg & Format(rst!开船时间, "yyyy年mm月dd日") & ","
rst.MoveNext
Wend
rst.Close
MsgBox strmsg, 48, "以下日期自动过帐不成功,请进行手动过帐,再结算"
Exit Sub
End If
不明白,
比如:我查询到的表中状态为0的开船时间是5月1日 5月6日 5月8日 ,状态为1的开船时间是5月2日,5月3日
而我的时间段是5月1日-9日
在时间段里有但表中没有的时间是5月4日 5月5日 5月7日 5月9日,我下面代码得到的strmsg是状态为0的开船时间
是5月1日 5月6日 5月8日,而我想改得到的是strmsg是5月1日 5月6日 5月8日 5月4日 5月5日 5月7日 5月9日
既状态为0的开船时间和在时间段里但不在表里的时间,请问如何实现啊?谢谢 Dim msql As String
Dim strmsg As String
msql = "select 过帐状态表.开船时间 as 开船时间 from 过帐状态表 where 状态 = '0' and 开船时间 between '" & starDT & "' and '" & endDT & "' group by 开船时间"
Set rst = cn.OpenResultset(msql, rdOpenStatic, rdConcurReadOnly)
If Not rst.EOF Then
While Not rst.EOF
strmsg = strmsg & Format(rst!开船时间, "yyyy年mm月dd日") & ","
rst.MoveNext
Wend
rst.Close
MsgBox strmsg, 48, "以下日期自动过帐不成功,请进行手动过帐,再结算"
Exit Sub
End If
记得好像有这么一种嵌套方法 你查一下吧