以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]关于按钮自动生成编号  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=93971)

--  作者:rxfmrqq
--  发布时间:2016/12/12 14:43:00
--  [求助]关于按钮自动生成编号

Dim dr As DataRow
dr = DataTables("销售明细").AddNew()
dr("时间") = Date.Today
With Tables("销售明细")
    .Position = .Position + 1
End With

Dim d As Date = e.Form.Controls("DateTimePicker时间").Value
Dim y As Integer = d.Year
Dim m As Integer = d.Month
Dim Days As Integer = Date.DaysInMonth(y,m)
Dim fd As Date = New Date(y,m,1)
Dim ld As Date = New Date(y,m,Days)
Dim bh As String = Format(d,"yyyyMM")
Dim max As String
Dim idx As Integer
 max = DataTables.Compute("Max(编号)","日期 = #" & e.DataRow("日期") & "# And [_Identify] <> " & e.DataRow("_Identify"))
If max >""then
idx = CInt(max.Substring(9,3)) + 1
Else  
 idx =1
End If
dr("单据编号") =  bh & "-" & Format(idx,"000")

 

 

老师好

我在按钮的 click中写下这段代码。

但是  max = DataTables.Compute("Max(编号)","日期 = #" & e.DataRow("日期") & "# And [_Identify] <> " & e.DataRow("_Identify"))
这句老是不正确,

我应该用什么词汇来替代 e.datarow呢?

 


--  作者:有点蓝
--  发布时间:2016/12/12 14:49:00
--  
DataTables.Compute("Max(编号)","日期 >= #" & fd & "# and 日期 <= #" & ld & "#") 
--  作者:rxfmrqq
--  发布时间:2016/12/12 14:58:00
--  

额,老师, 我修改了之后发现。 Compute 也不能用在这里。

  是在 窗口按钮的 click 下的代码。

  如果 compute不能实现,我该参考什么资料呢?


--  作者:有点蓝
--  发布时间:2016/12/12 14:58:00
--  

DataTables("销售明细").Compute("Max(编号)","日期 >= #" & fd & "# and 日期 <= #" & ld & "#") 


--  作者:rxfmrqq
--  发布时间:2016/12/12 15:05:00
--  

老师, 非常感谢, 已经解决了。