The data type is text. i didn't realise i posted the one with .text i changed
it to see if it would work and then changed it back to .value. It also
retures #name? when it is all text seems to only work with numbers regard
less of the data type
:
I have never seen that. What is the data type of the field bound to the
control?
Why did you change from .Value to .Text?
--
Dave Hargis, Microsoft Access MVP
:
Apprenlty i was wrong when i said it works perfectly it works as long as
there are is only number as soon as text is imput i get #name in the text
box. For example with mill number K458475 the next record says #name. here is
the code again
Private Sub MillOrder_AfterUpdate()
With Me.MillOrder
.DefaultValue = .Text
End With
End Sub
thanks again
:
Oh, good, now I don't have go any crazier than I already am
![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
--
Dave Hargis, Microsoft Access MVP
:
Sorry about that last post it works perficatlly now. thanks for your help
:
Ok i changed it to be in the feet after update but it is still blank when i
go to a new record. here is my code again. Is there something else i am doing
wrong.
Private Sub Feet_AfterUpdate()
With Me.Feet
.DefaultValue = .Value
End With
End Sub
thanks again
:
Why are you trying to set the default value of the control named Feet in the
After Update of the control named TagNum?
You set the default value of a control in it's own After Update. If you
want to set the default value for Feet, then put it in the After Update event
of Feet. If you want to set the Default Value of TagNum, use TagNum, not
Feet.
Private Sub TagNum_AfterUpdate()
With Me.TagNum
.DefaultValue = .Value
End With
End Sub
Or
Private Sub Feet_AfterUpdate()
With Me.Feet
.DefaultValue = .Value
End With
End Sub
--
Dave Hargis, Microsoft Access MVP
:
Sorry to bother you agian but i must be missing something i have:
Private Sub TagNum_AfterUpdate()
With Me.Feet
.DefaultValue = .Value
End With
End Sub
I changed the names as you suggested. And i think i have the names correct.
But when i go to a new record the text box is still empty. I also tryed
putting the code into the before update of the text box. I am very new to
access maybe there is something i am missing
thanks again for your help
Mary
:
I hope length is not a control name on your form. Length is an Access
reserved word. It is the property for several objects.
The error you are getting has to do with correctly identifying the object
names. If Length truely is a name, the best thing to do is change it. If
you can't then encluse it in brackets [Length] That will usually (but not
always) resolve the error.
The syntax I posted is correct, it is a matter of proper naming. The
definition is:
With Me.ControlName 'Everything from this point until End With
referes to the
'Control on this form Named ControlName
.DefalutValue = .Value 'Make the Default Value of this control equal to
the
'Current Value of the Control
End With 'Terminates the With statement
This is not correct:
Private Sub Tag_AfterUpdate()
Length.DefaultValue = Length.Value
End Sub
The Control named Length has no relation to the control named Tag
BTW, Tag is also a reserved word, don't use it.
You need to set the default value of the control you are in, not a different
control.
As to it entering anything in a text box, it will not. It will only show in
the text box when you go to a new record.
--
Dave Hargis, Microsoft Access MVP
:
When i used the with it says compile error: with object must be user-defined
type, object or variant. So i took the with out giving me the code below.
However it does not enter anything in the text box. and i am wonder what the
code would be to get the value of the last record for the same box
Private Sub Tag_AfterUpdate()
Length.DefaultValue = Length.Value
End Sub
thanks for your help
:
The most common way to do this is to set the Defalut Value property of the
control to which the field is bound to the current value of the control in
the control's After Update event.
Private Sub txtPartNo_AfterUpdate()
With Me.txtPartNo
.DefaultValue = .Value
End With
--
Dave Hargis, Microsoft Access MVP
:
I am desinging and inventory tracking system and was wondering if there is
anyway to have the textboxes in a form automatically fill in with the values
from the record before it. The reson for this is when duplicates of the same
thing come in the user does not have to reenter all the data only the data
specific to each one eg. bar code number.
Thanks for any help