Home

Optical Disc Publisher

     

Optical Disc Publisher

 

Introduction

In this exercise, we will develop an application for a small CD publishing company. The owner wants the prices to be calculated so a customer would get a discount if he orders more. To attract customers and encourage them to order more, she has decided to fix the prices so that the customer would pay:

  • $20/CD if she orders less than 20 units
  • $15/CD if she orders less than 50 units
  • $12/CD if she orders less than 100 units
  • $8/CD if she orders less than 500 units
  • $5/CD if she orders more than 500 units

Practical LearningPractical Learning: Creating the Application

  1. Start Microsoft Access
  2. Replace the default file name with Optical Disc Publisher
  3. Click Create
  4. Close the default table without saving it
  5. On the Ribbon, click Create
  6. In the Forms section, click Form Design
  7. Save it as PriceEvaluation
  8. To use the needed spin button, in the Controls section of the Ribbon, click the More button and click ActiveX Controls
  9. From the list, click Microsoft Forms 2.0 SpinButton
     
    Insert ActiveX Control
  10. Click OK
  11. Design the form as follows:
     
    Optical Disc Publisher
    Control Properties
    Form Caption: Optical Disc Publisher - Order Evaluation
    Navigation Buttons: No
    Modal: Yes
    Border Style: Dialog
    TextBox Label Caption: Number of CDs/DVDs/BDs:
    Name: txtQuantity
    Format: General Number
    SpinButton Name: sbQuantity
    Buddy Control: txtQuantity
    Max: 10000
    TextBox Label Caption: Unit Price:
    Name: txtUnitPrice
    Format: Fixed
    TextBox Label Caption: Total Price:
    Name: txtTotalPrice
    Format: Fixed
    Button Use the Command Button Wizard to create a button used to close the form. Set its Caption to Close and Name it cmdClose
  12. On the form, click the spin button
  13. In the Properties window, double-click On Updated
  14. Click its ellipsis button
  15. Implement the event as follows:
    Private Sub updQuantity_Change()
        Dim Quantity As Integer
        Dim UnitPrice, TotalPrice As Currency
        txtQuantity = updQuantity.Value
        Quantity = updQuantity.Value
    
        If Quantity < 20 Then
            UnitPrice = 20
        ElseIf Quantity < 50 Then
            UnitPrice = 15
        ElseIf Quantity < 100 Then
            UnitPrice = 12
        ElseIf Quantity < 500 Then
            UnitPrice = 8
        Else
            UnitPrice = 5
        End If
            
        TotalPrice = Quantity * UnitPrice
    
        txtUnitPrice = CStr(UnitPrice)
        txtTotalPrice = CStr(TotalPrice)
    End Sub
  16. To allow the user to enter a quantity value, access the LostFocus event of the txtQuantity text box and implement it as follows:
    Private Sub txtQuantity_LostFocus()
        updQuantity.Value = CInt(txtQuantity)
    End Sub
  17. Test the application

Optical Disc Publisher

Optical Disc Publisher

 
 
     
 

Home Copyright © 2005-2016, FunctionX