If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Duplicate value
I have a form with a subform on it. The subform has 5 fields, set up as
datasheet view: ID (autonumber) Start End Qty (sum of end-start) Line Type (combo box) I've been asked to see if the 'End' can automatically be entered at the 'Start' on the next line; however, there is upon occassion the need to change the start number. For example: ID Start End Qty Line 1 0 215 215 (whatever) 1 215 300 85 (whatever) 1 325 350 25 "" It would end there; continue to next record. I've been racking my brain and just can't seem to get anything from it. Thanks for any help! Cathy |
#2
|
|||
|
|||
Duplicate value
Would it be wrong if the End value did *not* equal Start + Qty?
a) "Yes: that would indicate a mistake." Remove the End column from your table. Then create a query, and type an expression like this into the Field row: [End]: [Start] + [Qty] You can use this query anywhere you would have used your table, and it can't go wrong. b) "No: There could be meaningful cases like that." Use the Afterupdate event procedure of Start and End to assign Qty (or of Start and Qty to assign End.) More information in: Calculated Fields at: http://allenbrowne.com/casu-14.html Please note that there are lots of reserved words in Access that can cause problems in your queries, forms and reports. Start and End are among them. You probably want to rename these to something else like StartNum. Here's a list to refer to when designing your tables: http://allenbrowne.com/Ap****ueBadWord.html -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "cathyt" wrote in message ... I have a form with a subform on it. The subform has 5 fields, set up as datasheet view: ID (autonumber) Start End Qty (sum of end-start) Line Type (combo box) I've been asked to see if the 'End' can automatically be entered at the 'Start' on the next line; however, there is upon occassion the need to change the start number. For example: ID Start End Qty Line 1 0 215 215 (whatever) 1 215 300 85 (whatever) 1 325 350 25 "" It would end there; continue to next record. I've been racking my brain and just can't seem to get anything from it. Thanks for any help! Cathy |
#3
|
|||
|
|||
Duplicate value
Thanks for the post Allen. You've given me some ideas to try out today.
I'll let you know how it turns out. Cathy "Allen Browne" wrote: Would it be wrong if the End value did *not* equal Start + Qty? a) "Yes: that would indicate a mistake." Remove the End column from your table. Then create a query, and type an expression like this into the Field row: [End]: [Start] + [Qty] You can use this query anywhere you would have used your table, and it can't go wrong. b) "No: There could be meaningful cases like that." Use the Afterupdate event procedure of Start and End to assign Qty (or of Start and Qty to assign End.) More information in: Calculated Fields at: http://allenbrowne.com/casu-14.html Please note that there are lots of reserved words in Access that can cause problems in your queries, forms and reports. Start and End are among them. You probably want to rename these to something else like StartNum. Here's a list to refer to when designing your tables: http://allenbrowne.com/Ap****ueBadWord.html -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "cathyt" wrote in message ... I have a form with a subform on it. The subform has 5 fields, set up as datasheet view: ID (autonumber) Start End Qty (sum of end-start) Line Type (combo box) I've been asked to see if the 'End' can automatically be entered at the 'Start' on the next line; however, there is upon occassion the need to change the start number. For example: ID Start End Qty Line 1 0 215 215 (whatever) 1 215 300 85 (whatever) 1 325 350 25 "" It would end there; continue to next record. I've been racking my brain and just can't seem to get anything from it. Thanks for any help! Cathy . |
#4
|
|||
|
|||
Duplicate value
On Mon, 25 Jan 2010 06:43:01 -0800, cathyt
wrote: I have a form with a subform on it. The subform has 5 fields, set up as datasheet view: ID (autonumber) Start End Qty (sum of end-start) Line Type (combo box) I've been asked to see if the 'End' can automatically be entered at the 'Start' on the next line; however, there is upon occassion the need to change the start number. For example: ID Start End Qty Line 1 0 215 215 (whatever) 1 215 300 85 (whatever) 1 325 350 25 "" It would end there; continue to next record. I've been racking my brain and just can't seem to get anything from it. Thanks for any help! Cathy I'm taking this question a bit differently than Allen apparently did: if you just want the Start field in a new record to default to the most recently record's End (but to still be editable), you can use the Form's AfterUpdate event to set the Default Value property: Private Sub Form_AfterUpdate() Me![Start].DefaultValue = """" & Me!End & """" End Sub A DefaultValue property is a String, hence the four quotemarks before and after; """" will be translated to a single " character in the string. -- John W. Vinson [MVP] |
#5
|
|||
|
|||
Duplicate value
John,
That works great! Thank you very much! Cathy "John W. Vinson" wrote: On Mon, 25 Jan 2010 06:43:01 -0800, cathyt wrote: I have a form with a subform on it. The subform has 5 fields, set up as datasheet view: ID (autonumber) Start End Qty (sum of end-start) Line Type (combo box) I've been asked to see if the 'End' can automatically be entered at the 'Start' on the next line; however, there is upon occassion the need to change the start number. For example: ID Start End Qty Line 1 0 215 215 (whatever) 1 215 300 85 (whatever) 1 325 350 25 "" It would end there; continue to next record. I've been racking my brain and just can't seem to get anything from it. Thanks for any help! Cathy I'm taking this question a bit differently than Allen apparently did: if you just want the Start field in a new record to default to the most recently record's End (but to still be editable), you can use the Form's AfterUpdate event to set the Default Value property: Private Sub Form_AfterUpdate() Me![Start].DefaultValue = """" & Me!End & """" End Sub A DefaultValue property is a String, hence the four quotemarks before and after; """" will be translated to a single " character in the string. -- John W. Vinson [MVP] . |
Thread Tools | |
Display Modes | |
|
|