July 30, 2005 at 4:19 am
In my case, user select and copy all fields then paste it (like new data), but data in one field must be reset to 0 (zero). I must show info message when user try pasteing data.
Is It possible in VB, to catch the user when try to paste data into form record.
Thanks!
July 30, 2005 at 2:58 pm
Yep you could do something like the following
Private Sub Text0_LostFocus()
'value must be set to 0
'Yell at the user and then change the value for him since he can not under
'stand simple instructions
If Text0 <> 0 Then
MsgBox "This text box must contain 0. I will change the value for you", vbOKOnly, "Error"
Text0 = 0
End If
End Sub
[edited to add comments like I should have in the first place]
July 30, 2005 at 3:59 pm
The above will work but a few questions:
1. Are these new records? if so set the default value for this textbox to 0 and disable it on the form then they can never get to it to put in the wrong data.
2. Are you changing all the values in existing records? This could really mess up your data.
3. Why must this field always be set to 0?
July 31, 2005 at 2:10 am
Some explanations
When user make a Paste this add new record of data but fields contain data from record where user copyed (not default values). This is problem.
Field contain data is represent how many pieces is finished. On new record this must be 0 (default value is 0), then user (or automatism) enter propriate value 1,2,3..., concerning on finished pieces. When this walue is equal value of pieces in other field, operation is finished and generate a propriate document.
When user paste data from previous document (other data is equal this is OK, just number of maked pieces must be 0) number of pieces is equal finished pieces and here is the problem.
July 31, 2005 at 5:42 am
Dorinq did you develop you form with VB or with Access. If you used VB please post your code and I can help. If you used Access to make your form I am not so sure I can help.
I am still unclear as to the porcess you use. If the user is creating a new record he cuts and paste data from another source and the value of this field must be 0. When does this value get changed from 0 and who changes it?
July 31, 2005 at 10:38 am
Form is worked in Access 2003. Is datasheet subform on main form.
Subform contain a few record of data and user found shortcut to enter the data, just copy previous record and paste as new record. One field contain data how many pieces are finished and in this field must be value 0 (on new record). Of course, user must enter value 0 manualy if copy/paste data, in 99% they did, but in some cases forget ..... Now I must catch the paste operation and show message to the user.
On the other part of program, other users enter data on finished pieces and program automatic update value in problematic field in database (value = value + n). Pieces are worked in groups who contained n pieces. If the starting value is wrong rank is closed before any piece are finished and user can't enter data for finished pieces and,..... a lot of mess.
I can not show message for any new record just for pasted record.
August 1, 2005 at 12:18 am
thanks I will think about this tomorrw its late tonight or rather early this morning. Perhaps one of the big brains will have an answer before I do.
I will check back tomorrow.
Mike
August 1, 2005 at 8:20 am
Sorry I can not help you on this. I am not an expert on developing forms with Access. The Data control is quick and easy. But I prefer to design forms with VB and not use the data control as it limits the error checking you can do. I always use cmdButtons for adding and deleting and moving to the next record. If you can replace the data control with Seven buttons First,Last,Next,Previous,New,Update,Cancel then when the user clicked new to add the record you could check the value and set it to 0. On your subform you have no way of knowing when the user is changing the value.
Perhaps someone else can help.
Mike
[edit] My solution possted above will not work for what you want. You can check the value after the textbox loses focus onr when the record is updated. But you have no way of knowing if this is the first update (new record) or if the record is being changed correctly.
August 1, 2005 at 10:03 am
Thanks Mike.
I searching further ....
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply