Syntax issue with If then code

What is wrong with:  (the WHERE part of it must be wrong)

Me.txtSprayDate = Me.txtDatePlanted + Me.txtGR1 WHERE [PlantedID] = me.txtPlantedID
Who is Participating?
GozrehConnect With a Mentor Commented:
Like other says you can use WHERE only in a Query or SQL, not in middle of VBA

so you should change it to
Me.txtSprayDate = DLookup("DatePlanted + GR1","tbl","PlantedID=" & me.txtPlantedID)

depends what you need
Jim P.Commented:
Me.txtSprayDate = Me.txtDatePlanted And Me.txtGR1 WHERE [PlantedID] = me.txtPlantedID
SteveL13Author Commented:
Here is what I have but it doesn't work:

Me.txtSprayDate = Me.txtDatePlanted + Me.txtGR1 WHERE [ReadyID] = me.txtReadyID

Note that we need a plus mark not AND since it needs to add a number of days to the txtDate Planted
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Jim P.Commented:
Is this in a query, VBA code on a form or what? A little context would help.
SteveL13Author Commented:
What's wrong with it it's that the keyword WHERE is used inside a query or a SQL string and not in the context you're using it in. What exactly are you trying to do?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.