Remove extra using Update Query..

J

JOM

I would like to update email address as follows
First Name= John A. or John
Last Name = Smith
Email = (e-mail address removed) or (e-mail address removed)

This is how my code looks like:
************************************************************
Dim lngID As Long
Dim strEmail As String
Dim strSQL As String

Const q As String = "'"

lngID = Nz(Me.[YourID],0)

strEmail = Replace(Nz([FirstName],"x"), " ","") & "."
strEmail = strEmail & Replace(Nz([LastName],"x"), " ","")
strEmail = strEmail & ""@Company.com"

strSQL = "UPDATE tblEmployee SET [EmailAdd] = " & q & strEmail & q
strSQL = strSQL & " WHERE [YourID]=" & lngID

CurrentDB.Execute strSQL, dbFailOnError
Me.txtEmail.Requery
 
S

Steve Schapel

JOM,

Is there a problem?

On a quick scan, the only odd thing I can spot is 2 "s in the line...
strEmail = strEmail & ""@Company.com"
I think it should be...
strEmail = strEmail & "@Company.com"
 

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