473,491 Members | 2,205 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 using 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 1067
DS 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 using 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


Since you have "saved" the record for the order, and you are scanning,
you might want to do a search for the id supplied by the scanner for the
record.

I don't know if you could do this with a macro. Maybe. Macros aren't
my strong suit. Here's some sample code. MF = MainForm. SF = SubForm.
ID = ScannedID of the item scanned, OrderID = ID of order from MF..

In the BeforeUpdate event of the scan, enter something like

Sub BeforeUpdate_ID(....)
Dim blnCancel As Boolean
Dim rst As Recordset
Set rst = Forms!MF!SF.Form.Recordsetclone
rst.FindFirst "OrderID = " & Forms!MF!OrderID & " And " & _
"ItemID = " & Me.ScannedID
If not rst.NoMatch Then
rst.Edit
'add 1 to the qty. You can figure out the qty to add
'you could use an InputBox to get the qty.
rst!ItemQty = rst!ItemQty + 1
rst.Update
'no need to add record
blnCancel = True
Endif
set rst = Nothing
Cancel = blnCancel

'if you want to display a message
msgbox "This item already exists and the qty has been incremented by 1"

Endif
I suppose you could do something like this instead...needs to be tested.
If not rst.NoMatch Then
'clear out current record
Forms!MF!SF.Form.Undo

'move to the record
Forms!MF!SF!Form.Bookmark = rst.Bookmark
Endif

With some playing around you should be able to get it.
Nov 13 '05 #2

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

Similar topics

32
4092
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
3235
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
1700
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
4792
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
2092
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
2213
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
1406
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
1140
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
9220
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
5590
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
7115
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
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7190
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...
1
6858
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
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.