Private Sub Form_Open(Cancel As Integer)
m = DMax("FHID", "FHDB")
Me.FHDBZICT.Form.RecordSource = "SELECT FHDB.FHID, FHDB.RQ, FHDB.BH, FHDB.DD, FHDB.MCJGG," & _
"FHDB.SH, FHDB.DW, FHDB.XS, FHDB.DXSL, FHDB.DJ,FHDB.BZ, FHDB.KH FROM FHDB WHERE (((FHDB.FHID)>" & m & "));"
If DCount("RQ", "FHDB", "[RQ]=#" & Date & "#") = 0 Then
Me.BH = "JKH" & Format(Date, "yyyymmdd") & "001"
Else
Dim strbh1 As String, strbh2 As Integer
strbh1 = CurrentProject.Connection.Execute("SELECT Max(Val(Right([BH],3))) AS BH2 FROM FHDB GROUP BY mid([BH],4,8) HAVING (((mid([BH],4,8))=Format(Date(),'yyyymmdd')))").GetString
strbh2 = Val(strbh1) + 1
Me.BH = "JKH" & Format(Date, "yyyymmdd") & Format(strbh2, "000")
End If
End Sub
这段代码调整一下,呵呵