Delete a record after inform user (1 Viewer)

Falcon88

Registered User.
Local time
, 00:48
Joined
Nov 4, 2014
Messages
299
In a database for a store, there is a main form and a subform within it.

Required: If the user enters an item in the subform and its price is zero, upon leaving the main form the user will be notified that there are one or more items whose prices are zero and that they will be deleted, and the option is left to the user to run the deletion query or leave those items...
 

CJ_London

Super Moderator
Staff member
Local time
Today, 22:48
Joined
Feb 19, 2013
Messages
16,624
So little information provided so air code

if dcount(“*”, “sometable”, “price=0 and invnum=“ & invnum) then
If msgbox (“there are zero priced items, do you want to delete?”,vbyesno) =vbyes then
‘Delete zero priced records
End if
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:48
Joined
Sep 21, 2011
Messages
14,334
I do not understand why you would save a record, only to delete it?
 

Falcon88

Registered User.
Local time
, 00:48
Joined
Nov 4, 2014
Messages
299
I do not understand why you would save a record, only to delete it?
Suppose that the user, while entering many items, did not notice to the price of the item.

or you can guide me to a way to inform the user when he enters those items whose price is zero. After enters of them by the cboItemName combobox .
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:48
Joined
Sep 21, 2011
Messages
14,334
I could, but I know of someone who can say it better.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 22:48
Joined
Feb 19, 2013
Messages
16,624
or you can guide me to a way to inform the user when he enters those items whose price is zero.
Don’t allow them to select them in the first place - presume you are using a combo to select an item - so exclude them in the combo rowsource
 

GaP42

Active member
Local time
, 07:48
Joined
Apr 27, 2020
Messages
338
Normally an item selected for sale will be selected from a catalog, in which a price is set. A quantity is then used to determine the price to be charged. A discount can then be applied to that amount - it may be that the item is discounted 100% and so the amount charged is 0. Do you need to deal with that situation in your dialog?
BTW the catalog will have items which are currently available and some which may not be - eg out of stock/ no longer available, so your selection process needs to account for that.
 

tvanstiphout

Active member
Local time
Today, 14:48
Joined
Jan 22, 2016
Messages
225
Suppose that the user, while entering many items, did not notice to the price of the item.

or you can guide me to a way to inform the user when he enters those items whose price is zero. After enters of them by the cboItemName combobox .
I can guide you: in Form_BeforeUpdate of the subform write this:
if me.price = 0 then
cancel = true
msgbox "Yo! The price is zero. That is not allowed. Correct it, or delete this line item.", vbExclamation
end if
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 17:48
Joined
Feb 19, 2002
Messages
43,315
In the real world, sometimes the price IS zero. Using the BeforeUpdate event of the form, you can ask the user at the time the record is being saved. Do you want to save this record with a zero price. Very simple solution.
 

Users who are viewing this thread

Top Bottom