Results 1 to 2 of 2
  1. #1
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Select All Records Where [OrderStatus] = "Awaiting Approval"

    I want to do the above, where the control is OrderStatus and it's default is Awaiting Approval


    OrderStatus has 2 values, Awaiting Approval and Allocated

    If the records Status are NOT set to Allocated, then proceed with code,else do nothing. I want to skip all the records where the status is already set to Allocated.
    I guess I am having a brain fart, can't think. Here is the complete code that runs when the command button is clicked.

    'DoCmd.RunCommand acCmdSelectAllRecords
    'If [OrderStatus] = "Awaiting Approval" Then ' Here is where my brain stops.

    Dim AddItemsAsInventorymsgbox As String


    If Me!OrderStatus = "Allocated" Then 'Checks if Order has been Posted already.
    MsgBox "Order Has Already Been Posted"
    Exit Sub
    End If

    AddItemsAsInventorymsgbox = MsgBox("Do you want to Allocate these items to inventory? This is non reversible", vbInformation + vbYesNo, "OrderDetailsSubform")

    If (AddItemsAsInventorymsgbox = vbYes) Then
    DoCmd.SetWarnings False

    If Me.NewRecord Then 'Subtract From Inventory
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset

    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("Products", dbOpenTable)

    rst.Index = "PrimaryKey"
    rst.Seek "=", Me!ProductID
    rst.Edit
    rst("Inventory") = rst("Inventory") - Me!Quantity ' Subtracts items from Inventory
    rst("Sold") = rst("Sold") + Me!Quantity 'Adds items to Sold quantity
    rst.Update
    rst.Close

    Set rst = Nothing
    Set dbs = Nothing
    End If

    Me.[OrderStatus] = "Allocated"
    DoCmd.SetWarnings True
    DoCmd.Save
    If Me.Dirty Then Me.Dirty = False 'Forces a Save Record.
    End If
    Last edited by burrina; 11-27-2012 at 02:20 AM. Reason: Further Explanation:

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    I figured it out. Maybe the brain fart has let up!

    Me.Filter = "OrderStatus = ""Awaiting Approval"""
    Me.FilterOn = True

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 10-08-2012, 09:01 AM
  2. Replies: 2
    Last Post: 06-12-2012, 09:47 AM
  3. SELECT "False" if any records are false?
    By Azurewrath in forum Queries
    Replies: 6
    Last Post: 12-21-2011, 03:36 PM
  4. ComboBox "Select" and "DLookUp"
    By witooldas in forum Forms
    Replies: 0
    Last Post: 03-23-2011, 03:31 AM
  5. Replies: 4
    Last Post: 10-18-2010, 09:44 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums