0% found this document useful (0 votes)
6 views3 pages

Access VBA Code for Purchase Orders

Uploaded by

qasimcarnby
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Access VBA Code for Purchase Orders

Uploaded by

qasimcarnby
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Sub OpenOrder(Optional PurchaseOrderID As Long)

If (PurchaseOrderID > 0) Then


[Link] "Purchase Order Details", acNormal, , "[Purchase Order ID]="
& PurchaseOrderID, acFormEdit, acDialog
Else
[Link] "Purchase Order Details", acNormal, , , acFormAdd, acDialog
End If
End Sub

PurchaseContainsLineItems = [Link]
> 0

Private Sub ClassName_KeyDown(KeyCode As Integer, Shift As Integer)

'Dim intShiftDown As Integer, intAltDown As Integer


'Dim intCtrlDown As Integer

' Use bit masks to determine which key was pressed.


'intShiftDown = (Shift And acShiftMask) > 0
'intAltDown = (Shift And acAltMask) > 0
'intCtrlDown = (Shift And acCtrlMask) > 0
' Display message telling user which key was pressed.
'If intShiftDown Then MsgBox "You pressed the SHIFT key."
'If intAltDown Then MsgBox "You pressed the ALT key."
'If intCtrlDown Then MsgBox "You pressed the CTRL key."
Dim intShiftDown As Integer, intAltDown As Integer
intShiftDown = (Shift And acShiftMask) > 0
If intShiftDown Then
MsgBox "You pressed the SHIFT key."
[Link] acForm, "cc"
End If

End Sub

curX = DSum("[Freight]", "Orders", "[ShipCountry] = 'UK'")


Dim curX As Currency
curX = DSum("[Freight]", "Orders", _
"[ShipCountry] = 'UK' AND [ShippedDate] > #1-1-95#")

curX : DSum("[qty]";"ordersub";"[productid] = [productid] and


[ordersubnumber]=[ordersubnumber]")

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)


If KeyCode = vbKeyReturn Then
If Not Shift = acCtrlMask Then
MsgBox "Enter"
KeyCode = 0
[Link]
End If
End If
End Sub

DSum("[Value]","[Query]","[ID]=" & [ID] & " And [Date]<=#" & Format([Date],


"yyyy\/mm\/dd") & "#")

Function IsLoaded(ByVal strFormName As String) As Boolean


' Returns True if the specified form is open in Form view or Datasheet view.
Dim oAccessObject As AccessObject

Set oAccessObject = [Link](strFormName)


If [Link] Then
If [Link] <> acCurViewDesign Then
IsLoaded = True
End If
End If

End Function

Function IsLoaded(ByVal strFormName As String) As Boolean


' Returns True if the specified form is open in Form view or Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed


Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function

Private Sub Command284_Click()

[Link] acCmdRefresh

Dim strFormName As String

If [Link]("Purchase Orders").IsLoaded Then


strFormName = "Purchase Orders"
ElseIf [Link]("Purchase Orders New").IsLoaded Then
strFormName = "Purchase Orders New"
End If

Function DeleteARecord
If MsgBox("Do you wish to delete this record?", vbYesNo, "Delete Confirmation") =
vbYes Then
If MsgBox("Are you SURE you want to delete this record?" & vbCrLf & _
"This will permanently delete the record.", vbYesNo, "2nd Delete Confirmation")
= vbYes Then
[Link] acCmdDeleteRecord
End If
End If
End Function

Private Sub DeleteButton_Click()


DeleteARecord
End Sub

If MsgBox("Do you wish to delete this record?", vbYesNo, "Delete Confirmation") =


vbYes Then
If MsgBox("Are you SURE you want to delete this record?" & vbCrLf & _
"This will permanently delete the record.", vbYesNo, "2nd Delete Confirmation")
= vbYes Then
[Link] acCmdDeleteRecord
End If
End If

You might also like