473,395 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Combining Quantities

DS
Hi, I have an order entry form with a subform attached for order
details. Whenever you add a product to the Order Details subform and
then you try to add the same product again in won't let you. Which is
fine. The problem I'm having is that I'll be sing a scanner to enter
products and when you have two products in a row I need the subform to
make the quantity 2 not give me an error message that I already have the
product entered. I tried a work around by allowing duplicates, which
also works fine but now I have a product listed 2 or more times which
looks sloppy. Any solutions? If I write a Macro what would it say? If
I write code what would it say? Thanks Everyone,
DS
bo******@optonline.net
Nov 13 '05 #1
1 1074
You don't want duplicate products in an order. I would do it in code
like the following...

Use the form's BeforeUpdate event and its NewRecord property.

Private Sub Form_BeforeUpdate(Cancel As Integer)
'If this is a new record
If Me.NewRecord Then
'Check if it has already been entered
If Not IsNull(DLookup("ProdID", "tblOrdLines", "ProdID=" _
& Me.cboProd)) Then
'It has so lets just add the quantity to it
CurrentDb.Execute "UPDATE tblOrdLines SET OrdQty = " _
& "OrdQty + " & Me.txtQty & " WHERE OrdID = " _
& Me.OrdID & " AND ProdID=" & Me.cboProd, dbFailOnError
Cancel = True
Me.Undo
End If
End If

End Sub

Of course change the table, field and control names to match yours.

- Jim

On Sun, 26 Sep 2004 20:10:05 GMT, DS <bo******@optonline.net> wrote:
Hi, I have an order entry form with a subform attached for order
details. Whenever you add a product to the Order Details subform and
then you try to add the same product again in won't let you. Which is
fine. The problem I'm having is that I'll be sing a scanner to enter
products and when you have two products in a row I need the subform to
make the quantity 2 not give me an error message that I already have the
product entered. I tried a work around by allowing duplicates, which
also works fine but now I have a product listed 2 or more times which
looks sloppy. Any solutions? If I write a Macro what would it say? If
I write code what would it say? Thanks Everyone,
DS
bo******@optonline.net


Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
by: yukatan | last post by:
Maybe it's a newbie question, but if I have two strings, let's say s1="4" and s2="5", how can I get a new string of value "9", that is, add the two numbers. If I type: var newStr = s1 + s2 all I...
2
by: Chris Mullins | last post by:
I've spent a bit of time over the last year trying to implement RFC 3454 (Preparation of Internationalized Strings, aka 'StringPrep'). This RFC is also a dependency for RFC 3491...
3
by: alwayswinter | last post by:
I currently have a form where a user can enter results from a genetic test. I also have a pool of summaries that would correspond to different results that a user would enter into the form. I...
7
by: Barry | last post by:
Hi all, I've noticed a strange error on my website. When I print a capital letter P with a dot above, using & #7766; it appears correctly, but when I use P& #0775 it doesn't. The following...
5
by: M.Stanley | last post by:
Hi, I'm attempting to create a query that will combine 2 columns of numbers into one. The followng comes from 1 table with 4 fields (A,B,C,D) A B RESULT 700 000 700000 700 001 ...
3
by: Flip | last post by:
I'm looking at the O'Reilly Programming C# book and I have a question about extending and combining interfaces syntax. It just looks a bit odd to me, the two syntaxes look identical, but how does...
1
by: Robert Dodier | last post by:
Hello, I am interested in the problem of communicating physical quantities, e.g. between a web service and its client. I am sure there has been a lot of work on that, so there seems no need for...
1
by: jzint | last post by:
I have a parts inventory table that contains a catergory, qty, part # , and a description field. It is updated by a form that either adds to or subtracts from the inventory totals. What I am...
3
by: patrickdepinguin | last post by:
Hi, I need to write large quantities of data to a file in C. The data comes from statistics that are continuously gathered from a simulator, and in order to not slow the whole thing down I would...
5
by: Tristan Miller | last post by:
Greetings. Is it possible using HTML and CSS to represent a combining diacritical mark in a different style from the letter it modifies? For example, say I want to render Å‘ (Latin small letter...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.