Database Design: Line Items & Additional Items - vb.net

I am looking for a solution or to be told it simply is not possible/good practice.
I currently have a database whereby I can create new orders and select from a lookup table of products that I offer. This works great for the most part but i would also like to be able to add random miscellaneous items to the order. For instance one invoice may read "End of Tenancy Clean" and the listed product but then have also an entry for "2x Lightbulb" or something to that effect.
I have tried creating another lookup table for these items but the problem is i don't want to have to pre-define every conceivable item before I can make orders. I would much prefer to be able to simply type in the Item and price when it is needed.
Is there any database design or workaround that can achieve this? Any help is greatly appreciated. FYI I am using Lightswitch 2012 if that helps.

One option I've seen in the past is a record in your normal items table labeled something like "Additional Service", and the application code will recognize this item and also require you to enter or edit a description to print with the invoice.

In the ERP system which we have at work, there is a flag in the parts table which allows one to change the description of the part in orders; in other words, one lists the part number in the order and then changes the description. This one off description is stored in a special table (called NONSTANDARD) which basically has two fields - an id field and the description. There is a field in the 'orderlines' table which stores the id of the record in the special table. Normally the value of this field will be 0, which means that the normal description of the part be displayed, but if it's greater than 0, then the description is taken from the appropriate row in the nonstandard table.

You mean something like this?
(only key attributes included, for brevity)

Related

Ms Access SQL Limit control by previous field value

In a recipe database I have two tables. One has the ingredients of every recipe [Recipe_ingr] and the other the available measures and weight for every ingredient [Weight2].
When I input a new ingredient for a recipe, I would like to be able to choose the available units for only that specific food.
I have tried with this expression in the control field but it prompts me to choose first, and then the options remain the same for all the records, not changing dinamically according to the record ingredient code.
SELECT [Weight2].[Msre_Desc], [Weight2].[Gm_Wgt] FROM Weight2 WHERE Weight2.NDB_No Like Recipe_Ingr.NDB_No ORDER BY [Msre_Desc], [Gm_Wgt];
Picture of my tables
Update:
I tried the syntax change suggested by June9 but still the control doesn't update automatically with every record as you can see in this picture: Table
Suggest you name controls different from fields they are bound to, like tbxNDB. The SQL needs to reference a field or control that is on the form. Also, LIKE operator without wildcard accomplishes nothing that an = sign wouldn't. Also recommend not using exactly same name for fields in multiple tables.
If you use that SQL statement in combobox RowSource, try:
SELECT Msre_Desc, Gm_Wgt FROM Weight2 WHERE NDB_No = [tbxNDB] ORDER BY Msre_Desc, Gm_Wgt;
You want to save Msre_Desc as foreign key, not a record id generated by autonumber?

Acess Report - Sum the Value of a Field If the value of another Field Matches Criteria

I have an Access Database and i'm trying to create a report that has me a bit stumped. Basically this report is going to display each employee's order processing performance based on a user specified date range, the report gives an itemized detail of each unique product on the order and it's price and Quantity.
Each Product has an 'Assembly Category' either 'DRFLUSH' or 'FRAME'.
In the summary of each Order i want to total the Quantities of each Assembly Category in a separate field.
Initially i rushed this report and have now found that the way i intended on completing this task is incorrect as the value given is only a Count of how many times an instance of each value 'DRFLUSH' or 'FRAME' occurs. I started with as follows: (Please ignore the bad practice with field naming i have taken this database on from a previous employee).
=Count(IIf([ASSEMBLY ITEM CATEGORY]="FRAME",1,Null))
And
=Count(IIf([ASSEMBLY ITEM CATEGORY]="DRFLUSH",1,Null))
However as previously stated this is wrong. I want the fields to sum the Quantity of each line item but only where the criteria is matched.
Any help is greatly appreciated, i'm sure this is a ridiculously simple task however i just cannot seem to wrap my head around it today.
Thanks
Alex
Sorted this by changing the statements to as follows:
=Count(IIf([ASSEMBLY ITEM CATEGORY]="FRAME",[QTY],Null))
=Count(IIf([ASSEMBLY ITEM CATEGORY]="DRFLUSH",[QTY],Null))

MS Access manual Auto incrementing field

Im building a system for my company to keep track of internal orders, inbetween our warehouses, we have material that goes out warehouse 1 to warehouse 2 and we kind of lose track of how much of "x" is in warehouse 1 and how much in warehouse 2, so i want to implement this access db where a user fills a form and says: order 1: 500 of "x" order 2: 300 of "y". then another user fills an exit form where he says 1 of "x" going out, so i would need the program to keep track of total order and how much as gone out to fill order 1 and so on...
My idea here is to have both an order number and an id number for each of "x" everytime someoneone assembles 1 "x" they fill the form and print a label directly from the access (i have this part working already) while keeping a record of when it was assembled, who verified and what was verified (it will work as a quality control also).
What i dont know is how to program the db so when it reaches 500 of "x", the id number for "x" starts again from 1
This is the one major issue with my program right now, i'm not experienced in access db's or vba, but im getting there with a tip and a trick from here and there, so, no need to be careful with the technical language, i will google it if i have to :p
EDIT:
The table structure goes as follows:
1 table as the main table where I record the check that is made for every product, where I include the model of the product, the said ID that I want to reset after a number of products checked, and a concatenated field that includes most of this information to generate a qr code.
Then there is a table for the Order Number, which is connected to a form to record each new order with a date/time field, the order number itself and the number of products. This number of products must then be called from the code that will count how many products have been checked to date and keep the order number field updated so we can keep track of the order.
Then there is another minor table just to get values for the form, the product models
Thank you for your answers ;)
See this MSDN Documentation
Unfortunately in Access, you cannot 'reset' an ID field, unless you move the records to a newly created table and use that table for every 500 records.
As for the user control and login form, I'm afraid those are separate questions that must be asked in a different thread.
To get you started:
You can set the RecordSource of a form to a table, and when users make entries, the data will be saved to the table. You can also use a form with controls (text boxes, comboboxes, etc.) and create a button that runs a query to insert these records into a table.
The login piece - you can encrypt the database with a password. That may/may not be sufficient.
I would suggest you change your schema, if possible. Something like the following:
Orders
OrderID (Autonumber)
ProductID (link to your Products table)
QuantityRequested
Deliverables
DeliverableID (Autonumber)
OrderID (link to your Orders table)
SequenceNumber: in the BeforeInsert event set this value equal to:
DCount("*", "Deliverables", "OrderID=" & Me.OrderID) + 1
I'm assuming that your form has a control named OrderID that is bound to the OrderID field of the Deliverables table.
The code uses the DCount() function to get the count of all the other deliverables that have already been created for this order. If this is the first deliverable, DCount() will return 0. It then adds 1 to this count to get the sequence number of the next deliverable.
If the new SequenceNumber is greater than the quantity requested, you could display a message saying that the order has been filled and cancel the creation of the Deliverable record.
This is just one approach and it is not a complete solution. I'm assuming that once assigned a sequence number a deliverable cannot be deleted. You might need to make allowances for deliverables that get lost or damaged. You could incorporate a status field to the Deliverable table to deal with this, but you would still need to make a decision about what to do with the SequenceNumber.

SRSS: Dynamic amount of subreports in a report

it might be possible I'm searching for the wrong keywords, but so far I couldn't find anything useful.
My problem is quite simple: At the moment I get a list of individual Ids through a report parameter, I pass them to a procedure and show the results.
The new request is like this: Instead of showing the list for all individuals at once, there should be a list for each individual id.
Since I'm quite a beginner in srss, I thought the easiest approach would be the best: Create a subreport, copy the shown list, and create a subreport per individual id.
The amount of this IDs is dynamic, so I have to create a dynamic amount of subreports.
Funny enought, this doesnt seem to be possible. This http://forums.asp.net/t/1397645.aspx url doesnt show exactly the problem, but it shows the limit of the subreports.
I even ran trough the whole msdn pages starting http://technet.microsoft.com/en-us/library/dd220581.aspx but I couldnt find anything there.
So is there a possibility, to create a loop like:
For each Individual ID in Individual IDs, create a subreport and pass ONE ID to this?
Or is there another approach I should use to make this work?
I tried to create a 'Fake'-Dataset with no sql query but just for iterating the id list, but it seems the dataset needs a data-source...
As usual, thanks so far for all answers!
Matthias Müller
Or is there another approach I should use to make this work?
You didn't provide much detail about what sort of information needs to be included in the subreport, but assuming it's a small amount of data (say, showing a personnel record), and not a huge amount (such as a persons sales for the last year), a List might be the way to go.
I tried to create a 'Fake'-Dataset with no sql query but just for iterating the id list, but it seems the dataset needs a data-source...
All datasets require a data source, though if you're merely hard-coding some fake return data, any data source will do, even a local SQL instance with nothing in it.

SAP Business One I Query inventory base on user defined field

I am running a query on a product. I need a field that will look at the user defined field which contains another product and check that stock level. Any help would be great.
What is the main objective?
Are you trying to check on that item because that item is the material/component? or act like a substitution?
Using UDF is quite not feasible as you have to get the link to the Item Master Data, and I have not figured out yet how to do that.
But if you are using it as substitution, why don't you use Alternative Item in Inventory > Item Management > Alternative Items? It will show on Sales Quotation for you to display it to customer. Or during Sales Order, you can get it displayed for alternative should your main item is shortage.
If you are using those item as a component, I suggest you use Bill of Material. During Production Order you will be able to see those component's availability in qty, and also you can have more than one, unlike UDF.
Hope this helps.
I think the key part you're missing here is the naming convention which SAP adpots for user defined fields.
Correct me if I'm wrong, but it seems that you're capable of querying these fields from a SQL point of view.
UDFs by defuault, will have their column name prefixed with "U_".
For example, the UDF 'AnotherProduct' will be referred to in SQL as 'U_AnotherProduct'.
Hope this helps, if not, please explain your problem in some more detail.