Duplicate value

  • Thread starter Thread starter cathyt
  • Start date Start date
C

cathyt

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
 
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/AppIssueBadWord.html
 
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 said:
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/AppIssueBadWord.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


cathyt said:
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 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,
That works great! Thank you very much!
Cathy

John W. Vinson said:
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.
 
Back
Top