Multiple Codes in AfterUpdate Event

C

cynteeuh

I have the below code in the afterupdate of a field in a form. I want to also
force it to all caps if someone were to paste into it. I have a sample code
below, but I don't know how to combine the two or if that were possible.

Thank you in advance for your help!

Private Sub Cube_AfterUpdate()

[M/S] = Replace(Left([Cube], 4), ".", "")

End Sub

I want to add the below code to the above, if possible:

Me!TextBoxName = UCase(Me!TextBoxName)
 
J

Jeanette Cunningham

Hi cynteeuh,
this should do it.

Private Sub Cube_AfterUpdate()

[M/S] = Replace(Left([Cube], 4), ".", "")
Me!TextBoxName = UCase(Me!TextBoxName)

End Sub



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
J

John W. Vinson

I have the below code in the afterupdate of a field in a form. I want to also
force it to all caps if someone were to paste into it. I have a sample code
below, but I don't know how to combine the two or if that were possible.

Thank you in advance for your help!

Private Sub Cube_AfterUpdate()

[M/S] = Replace(Left([Cube], 4), ".", "")

End Sub

I want to add the below code to the above, if possible:

Me!TextBoxName = UCase(Me!TextBoxName)

This is really confusing. You have TextBoxName and Cube and [M/S] with no
indication of what [M/S] might be - is it another control on the form? If so,
change its name; punctuation such as / or - or . and (especially) , in field
or controlnames WILL cause problems.

Guessing wildly in the dark, and assuming that you want to populate a control
named [M/S] with the value in Cube, stripped of periods and converted to upper
case, try

Me![M/S] = UCase(Replace(Left(Me![Cube], 4), ".", ""))
 
C

cynteeuh

John,

You guessed correctly. THANK YOU! That was much more simpler than I thought.

Truly appreciated!!!

John W. Vinson said:
I have the below code in the afterupdate of a field in a form. I want to also
force it to all caps if someone were to paste into it. I have a sample code
below, but I don't know how to combine the two or if that were possible.

Thank you in advance for your help!

Private Sub Cube_AfterUpdate()

[M/S] = Replace(Left([Cube], 4), ".", "")

End Sub

I want to add the below code to the above, if possible:

Me!TextBoxName = UCase(Me!TextBoxName)

This is really confusing. You have TextBoxName and Cube and [M/S] with no
indication of what [M/S] might be - is it another control on the form? If so,
change its name; punctuation such as / or - or . and (especially) , in field
or controlnames WILL cause problems.

Guessing wildly in the dark, and assuming that you want to populate a control
named [M/S] with the value in Cube, stripped of periods and converted to upper
case, try

Me![M/S] = UCase(Replace(Left(Me![Cube], 4), ".", ""))
 

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