ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¤lªí³æ¦Û°Ê§ó·s¶µ¦¸

[µo°Ý] ¤lªí³æ¦Û°Ê§ó·s¶µ¦¸

³Ìªñ¶R¤F¤@¥»·søʸê°T
Access2013¶i¾P¦sºÞ²z¨t²Î¹ê§@ªº®Ñ
¾Ç²ß«Ø¥ß¸ê®Æ®w
¥Ø«e¤]«Ø¦nÀ³¥Î¦A¤u§@¤W

¥u¬O°£¤F®Ñ¤¤ªº¨º¨Ç°ò¦¥\¯à¥~,
¤]¹Á¸Õ¤F¦Û¤v·s¼W¤@¨Ç¤u§@»Ý¨Dªº³øªí¸òªí³æ

¥H¤U¤º®e¬O·Ó®Ñ¥´ªºµ{¦¡½X
¥Ø«e·Q³æ¯Â¥u¬OÅý¤lªí³æ¦Û°Ê§ó·s¶µ¦¸
¦³¹Á¸Õ¦Û¤v­×§ï,¦ý¬OµLªk¥¿±`¨Ï¥Î
½ÐÀ°¦£«üÂI¸Ó¦p¦ó­×§ï,©ÎªÌ¦³¬ÛÃö¸ê®Æ³sµ²¥i¥Hª¦¤å
·PÁÂ

-----------------------------------------------------------

Private Sub Form_BeforeUpdate(Cancel As Integer)

    '¨M©w¥Ø«e°O¿ý¬O§_¬°·s°O¿ý
    If Me.NewRecord Then
   
        '©w¸q¤å¦r¦r¦êªºÅܼÆ
        Dim strSQL As String
        '¿é¤J¨ú±o¶i³f³æ·í¤é³Ì¤jªº¶i³f³æ¸¹½Xªº¬d¸ßSQL»yªk
        strSQL = "SELECT MAX(Seq) AS Seq " & _
                 "FROM PurchaseDetails " & _
                 "WHERE PurchaseID = '" & Form_¶i³f³æºûÅ@![PurchaseID] & "' "
        '©w¸q¸ê®Æ¶°ª«¥óRecordSetªºª«¥óÅܼÆ
        Dim rst As ADODB.Recordset
        '«Ø¥ß¸ê®Æ¶°ª«¥óRecordSet
        Set rst = New ADODB.Recordset
        '¶}±Ò¸ê®Æ¶°ª«¥ó,¥H³s±µ¦ÜStock¸ê®Æ®w
        rst.Open strSQL, CurrentProject.Connection
        '©w¸q³Ì¤j¶µ¦¸ªº¾ã¼ÆÅܼÆ
        Dim MaxSeq As Integer
        '±q¸ê®Æ¶°ª«¥ó¨Ó¨ú±o¬d¸ß¨ìªº³Ì¤j¶µ¦¸
        MaxSeq = Val(rst.GetString)
        '·sªº¶µ¦¸¬°³Ì¤j¶µ¦¸¥[1
        Me![Seq] = MaxSeq + 1
        'Ãö³¬¸ê®Æ¶°ª«¥óRecordset
        rst.Close
        'ÄÀ©ñ¸ê®Æ¶°ª«¥óRecordset©Ò¦û¥Îªº¸ê·½
        Set rst = Nothing
   
    End If
   
    '­pºâ¤p­pª÷ÃB(=¼Æ¶q*³æ»ù)
    Me![SubTotal] = Me![Quantity] * Me![Price]

End Sub

        ÀR«ä¦Û¦b : ºÉ¦h¤Ö¥»¥÷¡A´N±o¦h¤Ö¥»¨Æ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD