VbzCart/archive/code/VBA/Form frmPackages

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search

vbzcart-MSAccess-frmPackages-running.png

vbzcart-MSAccess-frmPackages.png
vbzcart-MSAccess-sfrmPackages.png

<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>