Access 2002 (XP)

Discussion in 'Scripting & Programming' started by wizard, Aug 18, 2007.

  1. wizard

    wizard Petabyte Poster

    5,767
    42
    174
    Got a couple of questions for you.

    I have this form and in it there is a field called "Qty Requisitioned".

    I want a pop up box to be displayed if the qty requisitioned is greater than what the figure is in stock.

    How would I go about doing this?

    This leads on to my second question, if the figure that is requisitioned is less than the figure in stock, how would I get the stock figure to reduce by how many that has been requisitioned?
     
    Certifications: SIA DS Licence
    WIP: A+ 2009
  2. ThomasMc

    ThomasMc Gigabyte Poster

    1,507
    49
    111
    an If..Else statement should be able to do this

    Code:
    [COLOR="purple"]Private Sub[/COLOR] btnOK_Click()
       
    [COLOR="purple"]Dim[/COLOR] sqlValue [COLOR="purple"]As Integer[/COLOR]
    [COLOR="purple"]Dim[/COLOR] tbValue [COLOR="purple"]As Integer[/COLOR]
    [COLOR="purple"]Dim[/COLOR] nSqlValue [COLOR="purple"]As Integer[/COLOR]
        [COLOR="green"]'Set the values[/COLOR]
        sqlValue = DLookup("Qty", "tblMain", "ID = " & Me.txtID.Value)
        tbValue = Me.TextBox1.Value
        [COLOR="green"]'Check if its below the current levels[/COLOR]
        [COLOR="purple"]If[/COLOR] tbValue > sqlValue [COLOR="purple"]Then[/COLOR]
             MsgBox ("Value is above current stock levels")
             [COLOR="purple"]Exit Sub[/COLOR]
        [COLOR="purple"]Else[/COLOR]
            [COLOR="green"]'TODO: Do something with the data, i assume you would like to update Qty &[/COLOR]
            [COLOR="green"]'create a matching order in another db[/COLOR]
            [COLOR="green"]'Set new stock level[/COLOR]
            nSqlValue = sqlValue - tbValue
            [COLOR="green"]'Inform the user[/COLOR]
            MsgBox ("Stock levels have been adjusted accordingly: " & nSqlValue & " Remaining")
        [COLOR="purple"]End If[/COLOR]
    [COLOR="purple"][COLOR="Purple"]End Sub[/COLOR][/COLOR]
    
    Hope this helps
     
    Certifications: MCDST|FtOCC
    WIP: MCSA(70-270|70-290|70-291)
  3. wizard

    wizard Petabyte Poster

    5,767
    42
    174
    Thomas,

    Thanks for the help, I've decided to make it a lot simpler, this was for a friend and I've decided I'm going to tell him to adjust and monitor his stock levels manually.
     
    Certifications: SIA DS Licence
    WIP: A+ 2009
  4. ThomasMc

    ThomasMc Gigabyte Poster

    1,507
    49
    111
    no worries bud
     
    Certifications: MCDST|FtOCC
    WIP: MCSA(70-270|70-290|70-291)

Share This Page

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.