Positioning cursor at end of default value

G

Guest

I am not getting a response on the Forms group but no
answers yet. Hopefully someone here can help
I have a text field on a form where I added a default value
(because people were always dropping the prefix required
on the PartInv field,causing problems later. It's a
temporary fix until we an link/import the inventory
tables). I also added the following OnEnter code
to place the cursor at the end of the default value but
I'm getting a RunTime Error '13', Type Mismatch. I have
something similar in a subform and that's works fine.
Code:
Me![PartInv].SelStart = Len(Me![PartInv])
Any ideas on what my error is?
 
R

Ron Weiner

Sounds like partInv could be Null and therefore lengthless, or you have
named the text box with the same name as the data, or both. I'd recommend
you re-name the text box txtPartInv and rewrite the code
me.txtPartInv.SelStart = Len(NZ(me.txtPartInv.Value,"")).

Ron W
 
G

Guest

Thank you very much. I don't know what you mean though
about naming: the field in the table is called PartInv but
the data is something like P2389.
-----Original Message-----
Sounds like partInv could be Null and therefore lengthless, or you have
named the text box with the same name as the data, or both. I'd recommend
you re-name the text box txtPartInv and rewrite the code
me.txtPartInv.SelStart = Len(NZ(me.txtPartInv.Value,"")).

Ron W
I am not getting a response on the Forms group but no
answers yet. Hopefully someone here can help
I have a text field on a form where I added a default value
(because people were always dropping the prefix required
on the PartInv field,causing problems later. It's a
temporary fix until we an link/import the inventory
tables). I also added the following OnEnter code
to place the cursor at the end of the default value but
I'm getting a RunTime Error '13', Type Mismatch. I have
something similar in a subform and that's works fine.
Code:
Me![PartInv].SelStart = Len(Me![PartInv])
Any ideas on what my error is?


.
 
R

Ron Weiner

All I am saying is the it is a bad idea to have the control on your form or
report have the same name as the column from the data source. This will
confuse Access since it can't tell weather you are referring to the data for
the control. Best to always disambiguate the two. If I have a text box
whose datasource was a column named PartInv I would name the text box
txtPartInv. This way access can always tell what it is the I am refering
to should I have an expression like txtPartInv.SelStart =
Len(NZ(me!PartInv,"")).

Ron W
Thank you very much. I don't know what you mean though
about naming: the field in the table is called PartInv but
the data is something like P2389.
-----Original Message-----
Sounds like partInv could be Null and therefore lengthless, or you have
named the text box with the same name as the data, or both. I'd recommend
you re-name the text box txtPartInv and rewrite the code
me.txtPartInv.SelStart = Len(NZ(me.txtPartInv.Value,"")).

Ron W
I am not getting a response on the Forms group but no
answers yet. Hopefully someone here can help
I have a text field on a form where I added a default value
(because people were always dropping the prefix required
on the PartInv field,causing problems later. It's a
temporary fix until we an link/import the inventory
tables). I also added the following OnEnter code
to place the cursor at the end of the default value but
I'm getting a RunTime Error '13', Type Mismatch. I have
something similar in a subform and that's works fine.
Code:
Me![PartInv].SelStart = Len(Me![PartInv])
Any ideas on what my error is?


.
 

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