remember the last entry in a text box on a form

  • Thread starter Thread starter asc4john
  • Start date Start date
A

asc4john

I am currently trying to get a form entry text box to remember the
last entry so as not to have to retype it each time.
I am using this code:

Private Sub tbxPartNumber_AfterUpdate()
tbxPartNumber.DefaultValue = tbxPartNumber
End Sub

The data entered is like 20-40-2345 as a string, but the default value
entered into the text box for the next record is -2365.
Is there a better way to do this? or How do I stop Access from doing
the calculation?

Thanks
 
What is the data type of the underlying field?

You could consider using the CStr() function to coerce the value of
txtPartNumber into a text/string format.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
What is the data type of the underlying field?

You could consider using the CStr() function to coerce the value of
txtPartNumber into a text/string format.

Regards

Jeff Boyce
Microsoft Office/Access MVP









- Show quoted text -

The field is text 50 characters and I tried Cstr but that did not
work.
 
Where did you try CStr()?

Regards

Jeff Boyce
Microsoft Office/Access MVP







- Show quoted text -

The only place I could think of tbxPartNumber.DefaultValue =
Cstr(tbxPartNumber). I also tried some MsgBoxes in the BeforeUpdate
and AfterUpdate and they showed 20-40-2345 but in the form and in the
table I have the difference. Different part number values produce the
same result (except the difference). MsgBoxes show the part number
but the form and table show/store the difference.
 
The fact that Access is calculating a difference rather than treating the
string as a string suggests that Access believes it is numeric, not text.
Try taking another look at all the places you may have defined or formatted
that information...

The table, naturally, but also in any forms, queries, ...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
The fact that Access is calculating a difference rather than treating the
string as a string suggests that Access believes it is numeric, not text.
Try taking another look at all the places you may have defined or formatted
that information...

The table, naturally, but also in any forms, queries, ...

Regards

Jeff Boyce
Microsoft Office/Access MVP







- Show quoted text -

The only add thing I can find is that text boxes placed in the form
header give format options, while text boxes in the detail section do
not give formatting options the drop-down is blank. Combo boxes in
the detail section do give formatting options.
There is no numeric use made of the part number field in the table,
forms or queries. I am using the above method on several combo boxes
and they work fine.
 
Sorry, I'm fresh out of ideas.

On occasion, when a control or a form just doesn't "behave", I've been known
to delete it and start over. If none of your objects calls for a numeric
formatting/data type, then maybe Access is confused and you just need to
rebuild that portion...?

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Sorry, I'm fresh out of ideas.

On occasion, when a control or aformjust doesn't "behave", I've been known
to delete it and start over. If none of your objects calls for a numeric
formatting/data type, then maybe Access is confused and you just need to
rebuild that portion...?

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP







- Show quoted text -

I usually put quotation marks around numbers with hyphens. It works
for me.
Just a thought.
 
I usually put quotation marks around numbers with hyphens. It works
for me.
Just a thought.- Hide quoted text -

- Show quoted text -

Tried that but it adds quotation marke into the table and I can not
have that, as it causes problems elsewhere.
The whole thing is just odd.
 
Back
Top