Copy Button Help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a form with several fields, one of them, is sometimes the same value
typed on the previous record. What Im trying to do is to place a button next
to the text field so the user can press it and copy the previos record value.

I need some help to develop the VB code to copy the previos value, should be
easy but im just starting...

Thanks for any comment.
 
Do your users know they can press Ctrl+' to copy the value from the previous
record in the same field?
 
No, they dont..thats why I want to place a button.
the button needs to do the same function, any idea? I think that is a simple
line but with databases I dont know how to do it
 
I would automate this with code in the After Update event of specific
controls. For instance a number value:
Me.txtNumericControl.DefaultValue = Me.txtNumericControl.Value
for text/string value
Me.txtStringControl.DefaultValue = """" & Me.txtStringControl.Value &
""""
for a date
Me.txtDateControl.DefaultValue = "#" & Me.txtDateControl.Value & "#"
 
Thanks Duane but i have already tried that solution before the post, and i
get a run time error 438...it seems that the 'default value' property can not
be recognized.
The line do work when you do a form directly from a table but not coming
from a query like my case. I dont know why...

Regards
 
is just this line:
Private Sub Command49_Click()
Me!Activity.DefaultValue = Chr(34) & Me!Activity & Chr(34)
End Sub

When you delete Defaultvalue and start to assign a property to "Activity"
the only one that prompts is 'value'....thats why i get an error 438 'Object
doesnt support the propery or method',,,but why dont?

The button is placed on a subform that has all the activities from a query
and the subform is linked with the main form by 'date'
 
Is just this line

Private Sub Command49_Click()
Me!Activity.DefaultValue = Chr(34) & Me!Activity & Chr(34)
End Sub

the error says;
Error 438
object doesnt support this property or method

When you delete default value and try to writte it again, after the
"activity." the only property that prompts is "value" thats why i get the
error.

Only happends when i do it in the subform that was made with a query.
If you use the code in a subform that comes directly from a table all runs
smooth
 
Change the name of the text box to txtActivity and then use your code like:

Private Sub Command49_Click()
Me!txtActivity.DefaultValue = Chr(34) & Me!txtActivity & Chr(34)
End Sub

BTW: consider changing the name of the command button to something that
makes sense to everyone.
 
thanks for the suggestion, I have cahnged the name now and the I still get
the error message....I will use the code with a form made from a table and
not coming from a query because that is the only way that is working.

Thanks 4all
 
Back
Top