Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Damm Text Boxes

Status
Not open for further replies.

Chance1234

IS-IT--Management
Jul 25, 2001
7,871
US
biggest oxymoron of all time "Microsoft Works"


Anyway, i have a textbox in a form in Access 97 and i need to protext the first 26 characters in that text box(prefix) All the usual methods such as attaching a string to the begiining of the field after update or default value in field I cant use due to the complexity of this database

Im sure there is some method under the key press event where you can return the position inside a text box

so the code would be something like

If PositionIntextbox <26 then
positionIntextbox = 27
end if

but have a feeling im thinking of a totally different language to VB

anyone got any ideas ?

Chance


 
Chance, not really sure what you mean by &quot;protext&quot;, by I think you mean that whatever the user types in the field, you want to have proceeded by some 26 character string. If I am correct, why not have two unbound textboxes, the first storing your 26 character string (not editable by the user) and the second taking their input. When you save the record, you would have to concatenate the two fields and then manually store them in the table using VBA.

Would this work? Other than that, I don't know a way to move through the positions of a textbox. Terry M. Hoey
 
To place a cursor you can use a combination SelLength, SelStart, and SelText functions (they are in help). You'd have to use it in concert with the len function I guess based on the information you gave. But I like Terry's idea better than going through all this work if it's always going to be 26 letters, just let them edit 27 on in another text box and save the value out in VBA when they're done.

HTH Joe Miller
joe.miller@flotech.net
 
unfortunatly its not that straight forward, btw sorry meant protect not protext. basicly there is a ton of criteria and possibilitys before arriving at whether that textbox is going to need a prefix or not. also it is very very important that the prefix only appears once, a stop gap solution I have got so far is this,

btw [Imm_Action] is the name of the field with the text box this bit is on another control on the form.

If [Status] = 4 Then
Me.[Imm_Action] = &quot;Refer To Front Office - &quot; & [Imm_ACtion]
End If

then on the text box for imm_Action I have


If Me![Status] = 4 Then
If Left(Me![imm_Action], 23) = &quot;Refer To Front Office -&quot; Then
Beep
Else
Me![imm_Action] = &quot;Refer To Front Office - &quot; & Me![imm_action]
End If
End If

this works to a degree but if someone part deletes the prefix &quot;Refer to Front Office-&quot; it will add in the prefix again.

the above is just a very simplified part of this DB believe me it is a lot more complicated.

but iam either remembering things that dont exist but , iam also thinking of another text control where you can grey out the begining words so the user can select, they can only add after the text ?

maybe i have drunk too much coffe today




 
What conditions cause you to want the &quot;Refer To Front Office - &quot; to be added to your string? If it is something that you can test for, then don't even store it, you are wasting space. Just test for it and display it when necessary... Terry M. Hoey
 
beleive me if i could i would, but im working on a Damm compliance thing so my flexibility is zero, as all these things have to start with this or end with this, or start this way or do this etc.

but! the control im refering to does exist, im trying to track it down at the moment, when i find out what it is Ill post it.

thanks anyway

Chance

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top