I am creating a database for a Warehouse Yard Management where a user can detect which dock doors are in use, inactive, or available. But its not working like it should. Basically if a truck driver arrives we assign it a dock door. After we assign a dock door then it checks that dock door is "In use" it is then it displays message then it undo. Then it checks to see if its "inactive" if it is then it displays message then it undo. If "dock doors" is empty then it changes the "dock doors" status to "In use" and the carrier to the carrier that the user inputed in the form. It somehow working but only in the order it arrives, for example if driver arrives and assign dock door #1 then the code works but lets say drive arrives and we try to assign dock door #8, then for some reason the code is not working, it has to be in order in order for it to work for some reason.... if you need further explanation please reply.... the "dockdoor_id" and "carrier_id" are number fields. here's the code:
Private Sub DockDoor_AfterUpdate()
Dim qdf As QueryDef
If Me.[DockDoor].Value = DLookup("DockDoor_ID", "tbl_YardDockDoors", "Status = 'IN USE'") Then
MsgBox "This Dock is unavailable. Please use another dock door", vbOKOnly, "Dock in use"
Me.[DockDoor] = Null
ElseIf Me.[DockDoor].Value = DLookup("DockDoor_ID", "tbl_YardDockDoors", "Status = 'INACTIVE'") Then
MsgBox "This Dock is INACTIVE. Please use another dock door", vbOKOnly, "Dock in use"
Me.[DockDoor] = Null
If Me.[DockDoor].Value = DLookup("DockDoor_ID", "tbl_YardDockDoors", "Status = 'EMPTY'") Then
CurrentDb.Execute "UPDATE tbl_YardDockDoors SET Status = '" & "IN USE" & "' " _
& "WHERE DockDoor_ID = " & Me.DockDoor, dbFailOnError
CurrentDb.Execute "UPDATE tbl_YardDockDoors SET Carrier_ID = '" & Me.Carrier_ID & "' " _
& "WHERE DockDoor_ID = " & Me.DockDoor, dbFailOnError
End If
End If
End Sub
Thank you very much!
Private Sub DockDoor_AfterUpdate()
Dim qdf As QueryDef
If Me.[DockDoor].Value = DLookup("DockDoor_ID", "tbl_YardDockDoors", "Status = 'IN USE'") Then
MsgBox "This Dock is unavailable. Please use another dock door", vbOKOnly, "Dock in use"
Me.[DockDoor] = Null
ElseIf Me.[DockDoor].Value = DLookup("DockDoor_ID", "tbl_YardDockDoors", "Status = 'INACTIVE'") Then
MsgBox "This Dock is INACTIVE. Please use another dock door", vbOKOnly, "Dock in use"
Me.[DockDoor] = Null
If Me.[DockDoor].Value = DLookup("DockDoor_ID", "tbl_YardDockDoors", "Status = 'EMPTY'") Then
CurrentDb.Execute "UPDATE tbl_YardDockDoors SET Status = '" & "IN USE" & "' " _
& "WHERE DockDoor_ID = " & Me.DockDoor, dbFailOnError
CurrentDb.Execute "UPDATE tbl_YardDockDoors SET Carrier_ID = '" & Me.Carrier_ID & "' " _
& "WHERE DockDoor_ID = " & Me.DockDoor, dbFailOnError
End If
End If
End Sub
Thank you very much!