Full Version: Set Value Using MID Function
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
jhawkfan79
Conditions...

1 Form with an unbound text box that I input a string like this: JA85YY777

After Update of the unbound text box, a macro fires with a setvalue

Setvalue contains a mid funciton to pull the "YY" from the inputted data and populate into a second unbound text box.

When I test the form, I continue to get "Type Mismatch" when it tries to set the value. Error message contains
[Forms]![frmNewLoc2]![txtID], Mid([Forms]![frmNewLoc2]![txtLocation],5,2)

Any ideas???
AC2Designs
Do you have code in your txt controls that may be setting something to a variable?
Can you post the code associated with this Form?

If the controls are unbound then there should not be a problem unless you have some code behind them...
strive4peace
instead of using a macro, put this on the control AfterUpdate event:

CODE
   if isnull(controlname1) then exit sub

   if len(me.controlname1) < 9 then
      msgbox "required format is AA99YY999",,"Enter new code"
      exit sub
   end if

   me.controlname_yy = Mid(me.controlname1,5,2)


How To Get Started Programming
http://www.utteraccess.com/forums/showflat...;Number=1230004
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.