Results 1 to 2 of 2
  1. #1
    aroque is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Posts
    8

    Angry Trying get a IfThenElse statement to work by comparing data in 2 different tables

    Hi everyone!,
    It has been a while since I've really needed some help. I know my indents are atrocious but i do this in spare time to help automate things at work and im still learning.Private Sub CmdProcess_Click() IF STATEMENT.txt

    Private Sub CmdProcess_Click()

    DoCmd.SetWarnings False

    If IsNull(Forms![Frm_InventoryMoves]![CmbTXName]) Then
    MsgBox "You MUST enter your name in the [Person Performing Transaction] box ", , "NO PERSON PERFORMING TRANSACTION !" ' Checks to see if Person Performming transaction field is empty
    Exit Sub
    End If
    Dim db As DAO.Database
    Dim tbl_Move_Temp2 As DAO.TableDef
    Dim tbl_Inventory As DAO.TableDef
    Dim partNum1 As String
    Dim partNum2 As String


    Set db = CurrentDb()
    Set tbl_Move_Temp2 = db.TableDefs("Tbl_Move_Temp2")
    Set tbl_Inventory = db.TableDefs("Tbl_Inventory")




    If CStr(partNum1) = CStr(partNum2) Then




    DoCmd.OpenQuery "Qry_Move_Consumption", acViewNormal
    DoCmd.OpenQuery "Qry_InventoryMoveConsumption Append", acViewNormal 'Appends consumption record to Archive


    DoCmd.OpenQuery "Qry_MoveTemp2Consumption DELETE", acViewNormal 'Deletes consumption items based on the 2nd temp table
    DoCmd.OpenQuery "Qry_InventoryAddition Update", acViewNormal ' Adds to location
    DoCmd.OpenQuery "Qry_InventorySubtract Update", acViewNormal ' Subtracts from locations
    DoCmd.OpenQuery "Qry_InventoryMove Append", acViewNormal 'Appends to the Archive file
    DoCmd.OpenQuery "Qry_CleanZeroInventory", acViewNormal 'Cleans Inventory
    Else
    DoCmd.OpenQuery "Qry_Move_Consumption", acViewNormal
    DoCmd.OpenQuery "Qry_InventoryMoveConsumption Append", acViewNormal 'Appends consumption record to Archive
    DoCmd.OpenQuery "Qry_MoveTemp2Consumption DELETE", acViewNormal 'Deletes consumption items based on the 2nd temp table
    DoCmd.OpenQuery "Qry_InventoryAddition Update", acViewNormal ' Adds to location
    DoCmd.OpenQuery "Qry_InventorySubtract Update", acViewNormal ' Subtracts from locations
    DoCmd.OpenQuery "Qry_InventoryMoveNewRecord APPEND", acViewNormal 'Appends the move to inventory table (Only if there isnt a record already)
    DoCmd.OpenQuery "Qry_InventoryMove Append", acViewNormal 'Appends to the Archive file
    DoCmd.OpenQuery "Qry_CleanZeroInventory", acViewNormal 'Cleans Inventory
    End If

    DoCmd.OpenQuery "Qry_MoveTemp2 DELETE", acViewNormal 'deletes records that were moved
    DoCmd.OpenQuery "Qry_MoveTempClean DELETE", acViewNormal 'Cleans top temp table
    Me![CmbName] = Null
    Me![Combo17] = Null
    DoCmd.ShowAllRecords
    [CmbPN].SetFocus
    DoCmd.SetWarnings True
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Please post code between CODE tags to retain indentation and readability. Use # icon on post edit toolbar. Can edit your post.

    What is your issue - error message, wrong result, nothing happens? Have you step debugged?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. VBA For Comparing Data From Multiple Tables
    By Botfly in forum Programming
    Replies: 4
    Last Post: 02-08-2019, 01:13 PM
  2. Comparing Data From Two Tables
    By dcoley in forum Access
    Replies: 12
    Last Post: 05-01-2014, 12:09 PM
  3. Replies: 5
    Last Post: 12-09-2012, 02:29 PM
  4. Query comparing data in two tables
    By KatyOftedahl in forum Queries
    Replies: 1
    Last Post: 07-07-2011, 04:48 PM
  5. Replies: 2
    Last Post: 02-21-2011, 01:31 PM

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