Restrick "closing order" Button being pressed if orders still outstanding (1 Viewer)

rainbows

Registered User.
Local time
Today, 04:21
Joined
Apr 21, 2017
Messages
425
below is my order and order details screen. there are 3 products required for this order. i have discovered that the "order shipped button is sometime being pressed before all 3 products have been shipped. these could be shipped at different dates when the order shipped buttom is pressed the order is not visable anymore

how can i get it that if the y try to press the order shipped button it sends a message telling them all the products have not been shipped

thanks
steve



1708077679164.png
 

Minty

AWF VIP
Local time
Today, 12:21
Joined
Jul 26, 2013
Messages
10,371
Use a dcount() on the order lines where Shipped = 0 and OrderNo = YourOrderNo
if it's more than 0 then all the order lines haven't shipped?
 

ebs17

Well-known member
Local time
Today, 13:21
Joined
Feb 7, 2020
Messages
1,946
I would also count what I send.

The question would still be whether I make the sending dependent on the count or just provide information afterwards.

You can also bring existing records that are no longer visible due to a given filtering back into the foreground by changing the filtering.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:21
Joined
May 7, 2009
Messages
19,244
well, the subform should set it automatically on the main form:

on subform current event:

Code:
private sub Form_current()
    dim rec_count as long, ship_count as long, bolShipComplete as boolean
    with me.recordsetclone
        if not (.bof and .eof) then
            .movelast
            .movefirst
            rec_count = .recordcount
        end if
        do until .eof
            ship_count = ship_count + !shipped
            .movenext
        loop
    end with
ship_count = abs(ship_count)
bolShipcomplete = (rec_count = ship_count) and (rec_count > 0)
if me!parent![order shipped] <> bolShipcomplete then
     me!parent![order shipped]  = bolShipComplete
    me!parent.dirty = false
end if
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:21
Joined
Feb 19, 2002
Messages
43,275
how can i get it that if the y try to press the order shipped button it sends a message telling them all the products have not been shipped
This is looking at the problem backwards. The user should never have to press a button to close the order. If final shipment is the key to the order close, then your shipping code should close the order automatically when the last item ships.
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:21
Joined
Sep 21, 2011
Messages
14,305
Apart from Pat's remark, I would be disabling the button until everything was shipped?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:21
Joined
Feb 19, 2002
Messages
43,275
The key is - don't make the user do something you can do yourself. You just leave yourself a logic hole that is totally unnecessary. It is bad enough having a "flag" to indicate complete (I didn't even mention why I generally won't do that) but I don't have a problem with it because sometimes figuring out "complete" in a query can be complex. Usually, it is pretty easy in your form code.
 

rainbows

Registered User.
Local time
Today, 04:21
Joined
Apr 21, 2017
Messages
425
Managed to look at this again , this is working good ok now , had to do a couple of changes albeit guess what i was doing.
thank you for all your help , as it was said much easier that it closes the order automatically

steve

Code:
Me.Parent.Refresh
    Dim rec_count As Long, ship_count As Long, bolShipComplete As Boolean
    With Me.RecordsetClone
        If Not (.BOF And .EOF) Then
            .MoveLast
            .MoveFirst
            rec_count = .RecordCount
        End If
        Do Until .EOF
            ship_count = ship_count + !shipped
            .MoveNext
        Loop
    End With
ship_count = Abs(ship_count)

bolShipComplete = (rec_count = ship_count) And (rec_count > 0)
If Me.Parent![Ordershipped] <> bolShipComplete Then
     Me.Parent![Ordershipped] = bolShipComplete
 
    Me.Parent.Dirty = False
End If

End Sub
 

Users who are viewing this thread

Top Bottom