Kamis, 16 Mei 2013

RE: [MS_AccessPros] How to - Code A2007

 

ZJubias-

See below...

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of moi
Sent: Thursday, May 16, 2013 10:08 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] How to - Code A2007

Hello everyone,

Am trying to learn how to code, can anyone please put an explanation in
plain English,on each line of the below code..

And at same time, please direct me a good link on how learn coding..

Thank you,
zjubias

-------------------
Private Sub cmdIssue_Click()
' Set an error trap
On Error GoTo trapError

' Declare a recordset
Dim rstLoan As DAO.Recordset
' If the bar code doesn't exist in tblLibraryStock
If IsNull(DLookup("StockBarcode", "tblLibraryStock", "StockBarcode = " &
Me!txtIssueBarcode)) = True Then
' Tell the user
MsgBox "Sorry - Barcode Does Not Exist", vbInformation, "Invalid
Barcode"
' And exit (I would have used Exit Sub)
GoTo leave
Else
' Open a recordset on jnkLoan
Set rstLoan = CurrentDb.OpenRecordset("jnkLoan", dbOpenDynaset)
' Find the last record that matches the current barcode
rstLoan.FindLast "StockBarcodeFK = " & Me!txtIssueBarcode
' If the record is found,
If rstLoan.NoMatch = False Then
' .. and it contains no return date
If IsNull(rstLoan!returndate) = True Then
' Tell the user the book is still out
MsgBox "Book Is Already On Loan. Please discharge before
Issuing.", vbExclamation, "Already On Loan"
GoTo leave
End If
End If
' Record not found - add it
rstLoan.AddNew
' Set the bar code .. and other fields in new record
rstLoan!StockBarcodeFK = Me!txtIssueBarcode
rstLoan!UserBarcodeFK = Me!UserBarcode
rstLoan!IssueDate = Date
rstLoan!DueDate = DateAdd("d", 30, Date)
' Save the new record
rstLoan.Update
' Requery the subOnLoan subform
Me!subOnLoan.Requery
' Clear the bar code in the current record
Me!txtIssueBarcode = Null
' Put the focus on the bar code (I would use
Me.txtIssuebarcode.SetFocus)
DoCmd.GoToControl "txtissuebarcode"
End If
' Exit code below
leave:
' If the recordset was opened,
If Not rstLoan Is Nothing Then
' Close the recordset and clear the variable
rstLoan.Close: Set rstLoan = Nothing
End If
Exit Sub
trapError:
MsgBox "Error " & Err.Number & ": " & Error$
Resume leave
End Sub
-------------------

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

Yahoo! Groups Links

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar