'自动生成凭证号码
Data1.RecordSource = "select * from  tb_djb order by 凭证号码"
Data1.Refresh
If Not Data1.Recordset.EOF Then Data1.Recordset.MoveLast
If lsph.Text = "" Then bh.Text = Date & "d" & Format(1, "###000")
If lsph.Text <> "" Then
  y1.Text = Month(Date)
  y2.Text = Month(Left(lsph.Text, 10))
  If y1.Text = y2.Text Then
    bh.Text = Date & "d" & Format(Val(Right(lsph.Text, 3)) + 1, "###000")
  End If
  If y1.Text <> y2.Text Then
    bh.Text = Date & "d" & Format(1, "###000")
  End If
End If
这个代码每次生成的号码都是一样的。不变。应该修改哪里,能让它自动编号,按顺序编号,帮忙修改一下,注明清楚!

解决方案 »

  1.   

    看的晕   貌似是用日期来当 凭证号的吧  
    bh.Text = Date & "d" & Format(1, "###000")
     因为 你date 是一样的 所以 bh.Text无论怎么样都是一样的
      

  2.   

    我已经解决了,谢谢各位啦!换了另外的表达。
    Dim temp1
        temp1 = Format(Date, "yyyymmdd")
        Adodc1.RecordSource = "select * from tb_djb where 凭证号码 like '%" + temp1 + "%'order by 凭证号码" '按凭证号码排序数据
        Adodc1.Refresh
      If Adodc1.Recordset.RecordCount > 0 Then
      Adodc1.Recordset.MoveLast
      bh.Text = Adodc1.Recordset.Fields("凭证号码")
      bh.Text = Val(Adodc1.Recordset.Fields("凭证号码")) + 1
      Else
      bh.Text = Format(Date, "yyyymmdd")
      bh.Text = bh.Text + "0001"
      End If
      Adodc1.RecordSource = "select*from tb_djb order by 凭证号码"
      Adodc1.Refresh