Compile error: Variable not defined - Access97

  • Thread starter Thread starter micfly
  • Start date Start date
M

micfly

I have a command button next to an email text box. When clicked it opens up
an email with the email address filled in the "to:" field.

I use this on three different forms in my database. Two of them work but one
is giving me an error. Here's the code: (The compile error highlights
Email2)

On Error GoTo Err_Command264_Click
Dim stDocName As String
stDocName = "mailto:" & (Email2)
Command264.HyperlinkAddress = stDocName
Exit_Command264_Click:
Exit Sub
Err_Command264_Click:
MsgBox Err.Description
Resume Exit_Command264_Click

Email2 is the name of the key in the table and is the control source for the
text box. I can't figure this out. It's the same code for all three email
buttons. They are all named different. I've tried changing Email2 to a
different name (in the table and form) but I still get the same error. What
is wrong???
Thanks
 
There's a good chance that Access is getting confused between controls and
variables. Be specific! If you have the contents of Email2 in a textbox,
then tell Access that it's in a control:
stDocName = "mailto:" & Me!Email2

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Back
Top