Solved

Syntax issue with If then code

Posted on 2014-01-30
6
154 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
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

895 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now