VbzCart/docs/archive/code/VBA/Form frmPackages: Difference between revisions

From Woozle Writes Code
< VbzCart‎ | docs‎ | archive‎ | code‎ | VBA
Jump to navigation Jump to search
imported>Woozle
(Created page with "<VB> Option Compare Database Option Explicit Dim intPkg As Long Dim objPkg As clsPackage Public Sub AlertPackageChanged(iPackage As Long) intPkg = iPackage UpdateStatu...")
 
imported>Woozle
(form screenshots)
Line 1: Line 1:
<VB>
[[File:vbzcart-MSAccess-frmPackages.png|400px|frame]]
[[File:vbzcart-MSAccess-sfrmPackages.png|400px|frame]]<VB>
Option Compare Database
Option Compare Database
Option Explicit
Option Explicit

Revision as of 12:08, 8 May 2014

<VB>

Option Compare Database Option Explicit Dim intPkg As Long Dim objPkg As clsPackage Public Sub AlertPackageChanged(iPackage As Long)

   intPkg = iPackage
   UpdateStatus

End Sub Private Property Get PackageExists() As Boolean

   If intPkg = 0 Then
       PackageExists = False
   Else
       Set objPkg = clsPackages.Item(intPkg)
       PackageExists = Not (objPkg Is Nothing)
   End If

End Property Private Sub UpdateStatus()

   Dim isPkg As Boolean
   isPkg = PackageExists
   Me.txtPkgCode.SetFocus  ' so we can disable buttons without checking which one has the focus
   Me.btnOrder.Enabled = isPkg
   Me.btnPkg.Enabled = isPkg
   If isPkg Then
       Me.btnShpmt.Enabled = objPkg.ShipmentExists
       Me.txtPkgCode = objPkg.Code
   Else
       Me.btnShpmt.Enabled = False
       Me.txtPkgCode = ""
   End If

End Sub Private Sub btnOrder_Click()

   UpdateStatus
   If PackageExists Then objPkg.Order.View

End Sub Private Sub btnPkg_Click()

   UpdateStatus
   If PackageExists Then objPkg.Edit

End Sub Private Sub Form_Activate()

   UpdateStatus

End Sub Private Sub Form_Load()

   UpdateStatus

End Sub Private Sub Form_Resize()

       With Me.sfrmPackages
           .Width = Me.InsideWidth - .Left
           .Height = Me.InsideHeight - .Top
       End With

End Sub </VB>