Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Syntax issue with If then code

Posted on 2014-01-30
6
Medium Priority
?
160 Views
Last Modified: 2014-02-01
What is wrong with:  (the WHERE part of it must be wrong)

Me.txtSprayDate = Me.txtDatePlanted + Me.txtGR1 WHERE [PlantedID] = me.txtPlantedID
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 38

Expert Comment

by:Jim P.
ID: 39822401
Me.txtSprayDate = Me.txtDatePlanted And Me.txtGR1 WHERE [PlantedID] = me.txtPlantedID
0
 

Author Comment

by:SteveL13
ID: 39822418
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
0
 
LVL 38

Expert Comment

by:Jim P.
ID: 39822441
Is this in a query, VBA code on a form or what? A little context would help.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

Author Comment

by:SteveL13
ID: 39822448
Form
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39822519
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?
0
 
LVL 10

Accepted Solution

by:
Gozreh earned 2000 total points
ID: 39822654
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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question