A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Duplicate value



 
 
Thread Tools Display Modes
  #1  
Old January 25th, 2010, 03:43 PM posted to microsoft.public.access.forms
cathyt
external usenet poster
 
Posts: 13
Default 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  
Old January 26th, 2010, 05:51 AM posted to microsoft.public.access.forms
Allen Browne
external usenet poster
 
Posts: 11,706
Default 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  
Old January 26th, 2010, 02:04 PM posted to microsoft.public.access.forms
cathyt
external usenet poster
 
Posts: 13
Default 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  
Old January 26th, 2010, 06:28 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default 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  
Old January 26th, 2010, 08:46 PM posted to microsoft.public.access.forms
cathyt
external usenet poster
 
Posts: 13
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:14 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.