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
|
|||
|
|||
Avoid Creating A Duplicate Record
When my form goes to a new record, I have a procedure that copies the last
record added to the form's underlying table into the form. The intent is that a series of new records may have the same data in many of the fields so I paste in the same values of the previous record and then edit what needs edited in the new record saving much retyping of the same data. Doing this however creates the definite possibility of creating a duplicate record. If after copying the previous record, no fields are edited, a duplicate record of the previous record is created. I'm looking for a way to detect if the new record has been edited after a copy of the previous record has been added to the form. I checked the Dirty property and the form is dirt after adding the copy of the previous record so using the dirty property seems to be out. Does anyone have any idea on what I can do? Thanks! Mark |
#2
|
|||
|
|||
Avoid Creating A Duplicate Record
Hi Mark
If you set the values in the new record by setting the DefaultValue for each control, instead of the Value, then the new record will not become dirty until the user types in some changes. The one catch is that the DefaultValue property is always a string expression, so strings and dates must be enclosed in quote marks. -- Good Luck! Graham Mandeno [Access MVP] Auckland, New Zealand "Mark" wrote in message nk.net... When my form goes to a new record, I have a procedure that copies the last record added to the form's underlying table into the form. The intent is that a series of new records may have the same data in many of the fields so I paste in the same values of the previous record and then edit what needs edited in the new record saving much retyping of the same data. Doing this however creates the definite possibility of creating a duplicate record. If after copying the previous record, no fields are edited, a duplicate record of the previous record is created. I'm looking for a way to detect if the new record has been edited after a copy of the previous record has been added to the form. I checked the Dirty property and the form is dirt after adding the copy of the previous record so using the dirty property seems to be out. Does anyone have any idea on what I can do? Thanks! Mark |
#3
|
|||
|
|||
Avoid Creating A Duplicate Record
Graham,
Thank you for the response! Would you explain further your last sentence about the DefaultValue property is always a string expression? If I wanted the following default values in different fields, what would I set the DefaultValue to: 4.5 $8.75 5/10/04 Miles Shipping Company Thanks, Mark "Graham Mandeno" wrote in message ... Hi Mark If you set the values in the new record by setting the DefaultValue for each control, instead of the Value, then the new record will not become dirty until the user types in some changes. The one catch is that the DefaultValue property is always a string expression, so strings and dates must be enclosed in quote marks. -- Good Luck! Graham Mandeno [Access MVP] Auckland, New Zealand "Mark" wrote in message nk.net... When my form goes to a new record, I have a procedure that copies the last record added to the form's underlying table into the form. The intent is that a series of new records may have the same data in many of the fields so I paste in the same values of the previous record and then edit what needs edited in the new record saving much retyping of the same data. Doing this however creates the definite possibility of creating a duplicate record. If after copying the previous record, no fields are edited, a duplicate record of the previous record is created. I'm looking for a way to detect if the new record has been edited after a copy of the previous record has been added to the form. I checked the Dirty property and the form is dirt after adding the copy of the previous record so using the dirty property seems to be out. Does anyone have any idea on what I can do? Thanks! Mark |
#4
|
|||
|
|||
Avoid Creating A Duplicate Record
Hi Mark,
Wanting to carry current values forward to the next record is fairly common. Someone else posted a similar question in microsoft.public.access My reply follows ============================================== Hi Maggie, Put the following in the AfterUpdate event of your form Const CQuote = """" 'that's two quotes, 4 quote marks Me!txtExamDate.DefaultValue = CQuote & Me!txtExamDate.Value & CQuote If you're going to use this code on more than one form I'd make CQuote a global constant. Otherwise it can go in the declarations area of the subroutine As you can see, if you have several TextBoxes that you want to hold the current value as the default just keep copying the Me!txtExamDate ... line and always change the name appropriately. Shame on me, I've lost the thread of attribution but I believe Allen Browne posted the code. ================================================== ====== HTH -- -Larry- -- "Mark" wrote in message k.net... Graham, Thank you for the response! Would you explain further your last sentence about the DefaultValue property is always a string expression? If I wanted the following default values in different fields, what would I set the DefaultValue to: 4.5 $8.75 5/10/04 Miles Shipping Company Thanks, Mark "Graham Mandeno" wrote in message ... Hi Mark If you set the values in the new record by setting the DefaultValue for each control, instead of the Value, then the new record will not become dirty until the user types in some changes. The one catch is that the DefaultValue property is always a string expression, so strings and dates must be enclosed in quote marks. -- Good Luck! Graham Mandeno [Access MVP] Auckland, New Zealand "Mark" wrote in message nk.net... When my form goes to a new record, I have a procedure that copies the last record added to the form's underlying table into the form. The intent is that a series of new records may have the same data in many of the fields so I paste in the same values of the previous record and then edit what needs edited in the new record saving much retyping of the same data. Doing this however creates the definite possibility of creating a duplicate record. If after copying the previous record, no fields are edited, a duplicate record of the previous record is created. I'm looking for a way to detect if the new record has been edited after a copy of the previous record has been added to the form. I checked the Dirty property and the form is dirt after adding the copy of the previous record so using the dirty property seems to be out. Does anyone have any idea on what I can do? Thanks! Mark |
#5
|
|||
|
|||
Avoid Creating A Duplicate Record
Hi Mark
I hope Larry's response has answered your question. To further elaborate, the DefaultValue property is seen as a string which is then evaluated as an expression. For example: MyControl.DefaultValue = "Date()" would cause the Date function to be called, which would return the current date. Similarly, MyControl.DefaultValue = "8/1/04" would cause the string to be evaluated as the expression "8 divided by 1 divided by 4", which would return the result 2. Presumably this would NOT be what was intended. To get the intended result, put the string in quotes: MyControl.DefaultValue = """8/1/04""" Or, to make this more readable, use Larry's suggestion and declare a constant for the quote character: Const cQuote = """" MyControl.DefaultValue = cQuote & "8/1/04" & cQuote For what you want to do, your default values will be derived from variables (or recordset fields), not constants, so you might do something like this: With Me.RecordsetClone .MoveLast Me.Field1.DefaultValue = cQuote & .Field1 & cQuote Me.Field2.DefaultValue = cQuote & .Field2 & cQuote ... etc End With You can also use the Form_AfterUpdate procedure to set change default values to the new data as new records are added. (Note that some sources suggest you enclose dates in hash signs (#), but I recommend quotes as preferable because the conversion of a quoted date will respect your regional date format settings, while #8/1/04# will always be interpreted as the US format of mm/dd/yy) -- Good Luck! Graham Mandeno [Access MVP] Auckland, New Zealand you could set the DefaultValue of a textbox to "Da "Mark" wrote in message k.net... Graham, Thank you for the response! Would you explain further your last sentence about the DefaultValue property is always a string expression? If I wanted the following default values in different fields, what would I set the DefaultValue to: 4.5 $8.75 5/10/04 Miles Shipping Company Thanks, Mark "Graham Mandeno" wrote in message ... Hi Mark If you set the values in the new record by setting the DefaultValue for each control, instead of the Value, then the new record will not become dirty until the user types in some changes. The one catch is that the DefaultValue property is always a string expression, so strings and dates must be enclosed in quote marks. -- Good Luck! Graham Mandeno [Access MVP] Auckland, New Zealand "Mark" wrote in message nk.net... When my form goes to a new record, I have a procedure that copies the last record added to the form's underlying table into the form. The intent is that a series of new records may have the same data in many of the fields so I paste in the same values of the previous record and then edit what needs edited in the new record saving much retyping of the same data. Doing this however creates the definite possibility of creating a duplicate record. If after copying the previous record, no fields are edited, a duplicate record of the previous record is created. I'm looking for a way to detect if the new record has been edited after a copy of the previous record has been added to the form. I checked the Dirty property and the form is dirt after adding the copy of the previous record so using the dirty property seems to be out. Does anyone have any idea on what I can do? Thanks! Mark |
Thread Tools | |
Display Modes | |
|
|