กระทู้เก่าบอร์ด อ.Yeadram
        
           1,881   2		  
          
					  
		    URL.หัวข้อ / 
		    URL
        
        โค้ด run autonumber      
    
      Private Sub ID_Click()
Dim strDate As String
Dim intNum As Integer, intMax As Integer
Dim strSuffix As String
strDate = Format([ShipDate], "yy")
If Me.ID = "" Or IsNull(Me.ID) Then
If IsNull(DMax("Val(Mid([ID],6))", "tblOrders", "Left([ID],2) = '" & strDate & " '")) Then
Me.ID = strDate & "-" & "001"
Debug.Print "1"
Else
intMax = DMax("Val(Mid([ID],6))", "tblOrders", "Left([ID],2) = '" & strDate & " '")
intMax = intMax + 1
Me.ID = strDate & "-" & Format(intMax, "000")
Debug.Print "1"
End If
End If
End Sub
จากโค้ด run autonumber ในฟอร์มโดยเลือกปี พ.ศ. จาก field [ShipDate]
มีปัญหาคือ ต้องการให้ช่วงเดือน 1 ต.ค. - 31 ธ.ค. ขึ้นปีงบประมาณใหม่ ต้องใช้ Dateserial อย่างไร ลองทำดูแล้วยังไม่ได้เลยค่ะ
    
    
  Dim strDate As String
Dim intNum As Integer, intMax As Integer
Dim strSuffix As String
strDate = Format([ShipDate], "yy")
If Me.ID = "" Or IsNull(Me.ID) Then
If IsNull(DMax("Val(Mid([ID],6))", "tblOrders", "Left([ID],2) = '" & strDate & " '")) Then
Me.ID = strDate & "-" & "001"
Debug.Print "1"
Else
intMax = DMax("Val(Mid([ID],6))", "tblOrders", "Left([ID],2) = '" & strDate & " '")
intMax = intMax + 1
Me.ID = strDate & "-" & Format(intMax, "000")
Debug.Print "1"
End If
End If
End Sub
จากโค้ด run autonumber ในฟอร์มโดยเลือกปี พ.ศ. จาก field [ShipDate]
มีปัญหาคือ ต้องการให้ช่วงเดือน 1 ต.ค. - 31 ธ.ค. ขึ้นปีงบประมาณใหม่ ต้องใช้ Dateserial อย่างไร ลองทำดูแล้วยังไม่ได้เลยค่ะ
				2 Reply in this Topic. Dispaly 1  pages and you are on page number 1 
				
        
    2 @R08167    
        
    
      ขอบคุณท่านอาจารย์ yeadram มากๆ เลยนะคะ  
    
    
   
    
      Time: 0.7105s
    
      
		
strDate = Format([ShipDate], "yy")
else
strDate=format(dateadd("yyyy",1,ShipDate),"yy")
end if