Gerry has attended:
Access VBA course
Procedures
On a form I have some code behind the 'on update' event procedure to change the case format of the entered text. The field is DoctName
if not isnull(DocName) then
DocName = Strconv(DocName,vbProperCase)
end if
I want to put this code behind other fields on the form but of course with the correct field name. Can I create a procedure and then call the procedure from the 'on update' for each relevant field on the form. If so how can I refer to the field name (which will of course change) in the procedure.
RE: Procedures
Yes you can by creating a procedure for instance
but may I suggest in the interest of simplicity you use the
ucase function
me.docname = UCase(me.docname.value)
just change the field name as appropriat e
if null is passed no error occurs - null is returned thus eliminating a needless check
ALTERNATIVELY SHOULD YOU WISH A GENERIC PIECE OF CODE
code
sub ChangeToU_Case( frmName as string , txtBoxName as string)
forms!frmname!txtBoxName.value = ucase(forms!frmname!txtBoxName.value)
forms!frmname.refresh
end sub
/code
CONTINUE.......
----------------------
on each of the after update EVENTS OF YOUR FIELDS
ChangeToU_Case(me.name & " " & Me.Text0.Name)
Replace the Text0 with the names of the fields on which you wish to implement the code
**********************************************
NB *****
CHECK BEFORE RUNNING AS I AM IN 2007 AND THINGS HAVE CHANGED MIGHTILY
jO