Some control properties that appear to be strings are actually variants and cannot be passed directly to an API function. For example:
gives a type mismatch error.
To avoid this you can explicitly convert to a string:
or copy into an intermediate string variable.
Dim server as string
server = Text1.caption
This applies whenever a variant is passed whether it is from a control, an object, or a locally declared variable.