Auto fill with value form previous record

M

Mary

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
 
K

Klatuu

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.
 
M

Mary

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


Klatuu said:
Oh, good, now I don't have go any crazier than I already am :)
--
Dave Hargis, Microsoft Access MVP


Mary said:
Sorry about that last post it works perficatlly now. thanks for your help

Mary said:
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
 
K

Klatuu

Doh!
I think I know the problem. Since it is text, it needs quotes. Sorry. Try
this

.DefaultValue = chr(34) & .Value & chr(34)

--
Dave Hargis, Microsoft Access MVP


Mary said:
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

Klatuu said:
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


Mary said:
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 :)
--
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
 
K

Klatuu

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


Mary said:
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


Klatuu said:
Oh, good, now I don't have go any crazier than I already am :)
--
Dave Hargis, Microsoft Access MVP


Mary said:
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
 
K

Klatuu

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
 
M

Mary

Sorry about that last post it works perficatlly now. thanks for your help

Mary said:
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

Klatuu said:
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


Mary said:
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
 
K

Klatuu

Glad I could help, Mary. Sorry about the extra work for you.
--
Dave Hargis, Microsoft Access MVP


Mary said:
Aweome it all works now thanks very much :)

Klatuu said:
Doh!
I think I know the problem. Since it is text, it needs quotes. Sorry. Try
this

.DefaultValue = chr(34) & .Value & chr(34)

--
Dave Hargis, Microsoft Access MVP


Mary said:
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 :)
--
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
 
K

Klatuu

Oh, good, now I don't have go any crazier than I already am :)
--
Dave Hargis, Microsoft Access MVP


Mary said:
Sorry about that last post it works perficatlly now. thanks for your help

Mary said:
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

Klatuu said:
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
 
M

missinglinq via AccessMonster.com

That will only work for a numeric field, Dave! For a text datatype it'll
give you #Name?, and for a date 12/20/99. Better to use:

For Text fields

Private Sub YourTextControlName_AfterUpdate()
If Not IsNull(Me.YourTextControlName.Value) Then
YourTextControlName.DefaultValue = """" & Me.YourTextControlName.Value &
""""
End If
End Sub

For Numeric fields

Private Sub YourNumericControlName_AfterUpdate()
If Not IsNull(Me.YourNumericControlName.Value) Then
YourNumericControlName.DefaultValue = Me.YourNumericControlName.Value
End If
End Sub

For Date fields

Private Sub YourDateControlName_AfterUpdate()
If Not IsNull(Me.YourDateControlName.Value) Then
YourDateControlName.DefaultValue ="#" & Me.YourDateControlName & "#"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top