473,382 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Combined WhereCondition Using Access2007

2
I need a complex query from a table
The first part alone works well
Expand|Select|Wrap|Line Numbers
  1.     Dim fechainicial As Date
  2.     Dim stDocName As String
  3.     Dim stLinkCriteria As String
  4. fechainicial = Text207
  5. fechafinal = Text209
  6.     stDocName = "Incidenciasenlabasededatos"
  7.     stLinkCriteria = "[Fecha]>=#" & fechainicial & "#" & " And " & "[Fecha]<=#" & fechafinal & "#"
  8.  
  9.     DoCmd.OpenForm stDocName, , , stLinkCriteria
The second alone works well
Expand|Select|Wrap|Line Numbers
  1.  If Texto167 = "Técnica" Then
  2.  
  3.     stLinkCriteria = "[Tipo de incidencia]='Técnica'"
  4.  
  5.     End If
but if I joint the two, does not work and I have I sintax error

Expand|Select|Wrap|Line Numbers
  1.  stLinkCriteria = stLinkCriteria & " And " & "[Tipo de incidencia]='Técnica'"
  2. or
  3.  
  4.  stLinkCriteria = stLinkCriteria & " Where " & "[Tipo de incidencia]='Técnica'"
  5.     MsgBox (stLinkCriteria)
Note.- in this case stLinkCriteria is the first one of course
I am missing something in the sintax . Can you help? Thanks
Oct 19 '08 #1
3 1640
RuralGuy
375 Expert 256MB
You do *not* use the word "WHERE" in a WhereCondition argument! Just use another AND.
Oct 19 '08 #2
emari2
2
You do *not* use the word "WHERE" in a WhereCondition argument! Just use another AND.
I already use another AND and something is wrong with the sintax as it gives me an error
Oct 19 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Hi. It seems to me that you've not thought through what will happen if the IF statement does not match the contents of Texto167. Since stLinkCriteria will be left as an empty string, the value of stLinkCriteria will then just become

Expand|Select|Wrap|Line Numbers
  1. stLinkCriteria = <empty string> & <your new criteria> 
  2. =>
  3. " AND [Tipo de incidencia]='Técnica'"
which is bound to generate an error.

Simplest solution is to move the AND to the end of the part within the IF:

Expand|Select|Wrap|Line Numbers
  1. stLinkCriteria = "[Tipo de incidencia]='Técnica' AND "
-Stewart
Oct 20 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: clintonG | last post by:
Is there a document that explains the difference between the Visual Studio .NET 2003 Combined Help Collection and the MSDN Library for Visual Studio .NET 2003 or does someone have comments...
2
by: Gobi | last post by:
Hello, I was wondering how to modify the Do.cmd wherecondition statement to filter not only for RATTY name but also for the "LAST" field that contain a "^" carrot in front of them...With the...
1
by: skt7460 | last post by:
I have a form with two (2) boxes where the user enters a min number in one and a max number in the other (e.g., 30 & 50). The command button has the below onclick event: Private Sub RANGE_Click()...
9
by: Ares6881 | last post by:
Hi everyone, I'm new to these forums, but I'm having a bit of an issue. I'm basically trying to get the coding right on the wherecondition, but can't seem to figure out the correct formatting for...
4
by: ARC | last post by:
I have a function in the OnNoData event for all my reports. Since converting to Access 2007, some reports w/ no data will come back fine with the following code. However, it seems a few that are...
1
by: kevooo5 | last post by:
I use Access 2003 and I'm having trouble setting the wherecondition for the Openform functions. Usually it would look something like this DoCmd.OpenForm "Contact", , ,wherecondition here I...
2
by: Steve | last post by:
I have been asked to convert an Access2002 database to Access2007. The database is used to manage a medium sized company. The company contact said that the existing database was put on a new...
1
by: fsunny | last post by:
Hi, i hv a application running fine in Access97. After convert it to .accdb in Access2007, i print report and there's the error message "The MS Access database engine could not find the object...
3
by: seepnezorf | last post by:
I keep a database of projects. I have a memo field in which I keep dated notes about the status. Above the memo field is a button called "update date." When I click on the button it adds into the...
7
by: rik | last post by:
I am trying to build an Access 2002/2003 database application that I would like to offer to other writers so they can track submissions. Just trying to make a helpful tool for writers, poets, or...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.