Solved

Syntax issue with If then code

Posted on 2014-01-30
6
155 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Modal form 11 30
Using Multiple  Filters (XLS and XLSX) in File selection dialog 6 34
Access Crosstab Query with Multiple Values 4 32
is Microsoft Access going to Die? 9 53
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
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…

803 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