Advertisement
| Hall of Fame |
|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: |
CREATE DATABASE Example GO USE Example GO CREATE TABLE ExampleMain ( ExampleMainID int NOT NULL identity(1,1) CONSTRAINT PK_ExampleMain PRIMARY KEY CLUSTERED, Multiplier decimal(20,5) NOT NULL CONSTRAINT DF_Example_Main DEFAULT (0) ) CREATE TABLE ExampleDetail ( ExampleDetailID int identity(1,1) CONSTRAINT PK_ExampleDetail PRIMARY KEY NONCLUSTERED, ExampleMainID int NOT NULL CONSTRAINT FK_ExampleExampleDetail_ExampleMainID FOREIGN KEY REFERENCES ExampleMain(ExampleMainID), CalcID int NOT NULL CONSTRAINT CK_ExampleDetail_CalcID_Valid CHECK (CalcID BETWEEN 1 AND 5), Number1 decimal(20,5) NOT NULL CONSTRAINT DF_Example_Number1 DEFAULT (0), Number2 decimal(20,5) NOT NULL CONSTRAINT DF_Example_Number2 DEFAULT (0) ) CREATE UNIQUE CLUSTERED INDEX IX_ExampleDetail ON ExampleDetail (ExampleMainID, CalcID) INSERT ExampleMain VALUES (2) INSERT ExampleMain VALUES (3) INSERT ExampleMain VALUES (4) INSERT ExampleDetail SELECT M.ExampleMainID, C.CalcID, Power(2, CalcID), Power(3, CalcID) FROM ExampleMain M CROSS JOIN (SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5) C (CalcID) GO CREATE PROCEDURE ExampleP @ExampleMainID int, @ExampleDetailID int = NULL AS SELECT M.ExampleMainID, D.CalcID, D.ExampleDetailID, M.Multiplier, D.Number1, D.Number2, CalcTotal = M.Multiplier * D.Number1 * D.Number2 FROM ExampleMain M INNER JOIN ExampleDetail D ON M.ExampleMainID = D.ExampleMainID WHERE M.ExampleMainID = @ExampleMainID OR D.ExampleDetailID = @ExampleDetailID GO /* Now use the provided ADP, and set its connection properties to the database you just created. It is set up to use (local) and integrated security. If you want or need to make the ADP yourself: 1. Open MS Access 2002 and select New Project (Existing Data). Provide connection information to the database you just created. 2. Create a form and set the following form properties: Record Source: EXEC ExampleP 0 Unique Table: ExampleDetail Resync Command: EXEC ExampleP NULL, ? Default View: Continuous Forms Navigation Buttons: No Scroll Bars: Vertical Only 3. Drop all available fields from the field list onto the form, creating text boxes. 4. Lock and slightly darken the background of the ExampleDetailID, Multiplier, and CalcTotal text boxes to indicate they cannot be edited. 5. Add the prefix "txt" to all text boxes. 6. Right-click on the detail bar and choose "Form Header/Footer" to add these. Add a locked and slightly darkened textbox in the form footer called txtSumCalcTotal with Control Source: =Sum([CalcTotal]) 7. Arrange the controls suitable for a continuous form (I put the labels in the header and the textboxes in a single row). 8. Save the form as ExampleSubform 9. Create a new form and set its properties: Record Source: SELECT * FROM ExampleMain 10. Drop all fields onto the form from the Field List. 11. Make the ExampleMainID textbox locked and slightly darken the background. 12. Drop a subform control and set properties: Source Object : ExampleSubform Name: ExampleSubform Record Selectors: No Do not link the subform and the main form with the wizard (though built-in Access linking can be part of your solution if necessary). 13. Set form properties: On Current: [Event Procedure] and click the "..." button to access the VB code for this event and set it as follows: Private Sub Form_Current() Me.ExampleSubform.Form.RecordSource = "EXEC ExampleP " & CStr(Nz(Me.ExampleMainID, 0)) End Sub 14. Set form properties: After Update: [Event Procedure] Set the code behind this event to: Private Sub Form_AfterUpdate() Me.ExampleSubform.Form.Requery End Sub 15. Save the form as ExampleForm. 16. Proceed as in the given experts-exchange question. */ GO -- When you're done, close the ADP and then clean up (make sure to close all open connections to the database): USE Master GO DROP DATABASE Example |