473,386 Members | 1,609 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,386 software developers and data experts.

Select query, trying to hard code

I am trying to hard code the following select query into a select case statement
ie (case1 <statment>, case 2 <statment>) but I getteing Compiler error: expected line number or label, or statement or end of statement on my select [VMS-CLT] line , with and without the pertentheses at the end of my where clause. here is what I have, the query functions proporly in the access query builder.

"SELECT [VMSU-CLT].Date, [VMSU-CLT].IDNumber, [VMSU-CLT].Time," _
& " [VMSU-CLT].CorrespondenceType, [VMSU-CLT].CallTakenBy, [VMSU-CLT].CallReferredTo," _
& " [VMSU-CLT].ReasonForReferral, [VMSU-CLT].Caller, [VMSU-CLT].VISTALastName," _
& " [VMSU-CLT].VISTAFirstName, [VMSU-CLT].VISTAMiddleName, [VMSU-CLT].State, [VMSU-CLT].ReasonForCall," _
& "[VMSU-CLT].[CalledVia800#], [VMSU-CLT].CallFollowUp, [VMSU-CLT].CallCompletdBy" FROM [VMSU-CLT]" _
& " WHERE ((([VMSU-CLT].Date)>=[forms]![Report query]![DateFrom] And ([VMSU-CLT].Date)<=[forms]![Repor query]![DateTo])))"
Feb 18 '08 #1
8 4446
puppydogbuddy
1,923 Expert 1GB
I am trying to hard code the following select query into a select case statement
ie (case1 <statment>, case 2 <statment>) but I getteing Compiler error: expected line number or label, or statement or end of statement on my select [VMS-CLT] line , with and without the pertentheses at the end of my where clause. here is what I have, the query functions proporly in the access query builder.

"SELECT [VMSU-CLT].Date, [VMSU-CLT].IDNumber, [VMSU-CLT].Time," _
& " [VMSU-CLT].CorrespondenceType, [VMSU-CLT].CallTakenBy, [VMSU-CLT].CallReferredTo," _
& " [VMSU-CLT].ReasonForReferral, [VMSU-CLT].Caller, [VMSU-CLT].VISTALastName," _
& " [VMSU-CLT].VISTAFirstName, [VMSU-CLT].VISTAMiddleName, [VMSU-CLT].State, [VMSU-CLT].ReasonForCall," _
& "[VMSU-CLT].[CalledVia800#], [VMSU-CLT].CallFollowUp, [VMSU-CLT].CallCompletdBy" FROM [VMSU-CLT]" _
& " WHERE ((([VMSU-CLT].Date)>=[forms]![Report query]![DateFrom] And ([VMSU-CLT].Date)<=[forms]![Repor query]![DateTo])))"
AFAIK, you can’t directly use a select case statement in an Access Query, but you can create a user defined function that uses the select case statement, Here is what you do:

1. create/copy your select case function called VMSCriteria() (for example) to a standard module (it needs to be a public function to be used with a query).
2. You can then reference the function in the criteria row of the field in your query grid as follows: VMSCriteria()
Feb 18 '08 #2
AFAIK, you can’t directly use a select case statement in an Access Query, but you can create a user defined function that uses the select case statement, Here is what you do:

1. create/copy your select case function called VMSCriteria() (for example) to a standard module (it needs to be a public function to be used with a query).
2. You can then reference the function in the criteria row of the field in your query grid as follows: VMSCriteria()
I'm not using the select case in the sql statement . I have a form that has the select case and depending what option the user picks on the form the apropriat query will exicute.
Mar 14 '08 #3
puppydogbuddy
1,923 Expert 1GB
ok, I misunderstood you. In taking another look, your error is a misspelled reference. Repor should be Report as indicated below:

& " WHERE ((([VMSU-CLT].Date)>=[forms]![Report query]![DateFrom] And ([VMSU-CLT].Date)<=[forms]![Repor<<<<<<<<<<< query]![DateTo])))"
Mar 15 '08 #4
Scott Price
1,384 Expert 1GB
If this is broken into two lines, as your error indicates, you need to add the underscore _ character to tell VBA that the statement is continued on the next line.

I notice that you have it in several places, but on that particular line not.

Regards,
Scott
Mar 15 '08 #5
If this is broken into two lines, as your error indicates, you need to add the underscore _ character to tell VBA that the statement is continued on the next line.

I notice that you have it in several places, but on that particular line not.

Regards,
Scott
That might help "_" :-p, somtimes another set of eyes helps with lines and lines of code,
I try it in the morning and let you know
I think there is more wrong then just that, becaue the query produces a report, so when I set my control source on my report to the form [Report query] I get an error stating that the form does not exist, when it does and I have even copied and pasted the form name into the control source of the report and got the same error.
Mar 15 '08 #6
Scott Price
1,384 Expert 1GB
The control source of your report should not be the name of the form, it should be the name of the query.

Regards,
Scott
Mar 15 '08 #7
The control source of your report should not be the name of the form, it should be the name of the query.

Regards,
Scott
your right, but in this case I am trying to hardcode my query into a form so I won't have an actual query , so thats why I think in this case it would be the name of the form
Mar 16 '08 #8
Scott Price
1,384 Expert 1GB
Well, if that was working for you, you wouldn't be here, eh? :-)

A form cannot act as a record source for anything! The form is only a container through which you interact with the data stored in underlying tables and passed (usually) through queries (either stored or hard-coded as SQL statements called through code).

Is there a significant reason why you cannot have a regular copy of this query to base the report on?

Regards,
Scott
Mar 16 '08 #9

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

Similar topics

16
by: lkrubner | last post by:
Are there any benchmarks on how much an extra, unneeded VARCHAR, CHAR, INT, BIGINT, TEXT or MEDIUMTEXT slows down a database call with MySql? PostGre info would also be useful. I'm trying to...
3
by: Hendry Taylor | last post by:
I have a problem where if I issue a select * from against a database it returns no data, but if I select column from it returns the data. Why would the * not be working as a wildcard?
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
6
by: GSteven | last post by:
(as formerly posted to microsoft.public.access.forms with no result) I've created a continuous form which is based on a straightforward table (ex - customers - 100 records). On the form there is...
3
by: Joe via DotNetMonster.com | last post by:
Hi, I'm trying to use several select statements so that I don't need to call the function several times. The next Result set always seems to read the first select statement. I have the...
8
by: daddydfsu via AccessMonster.com | last post by:
I am trying to create a ListBox based on a search from a TextBox. I have a TextBox where I will enter in a MemberAlias. I want to click on a Search Button and that will do a select from a...
8
by: Thomas | last post by:
Hi! I´m a newbie with this and I´m trying to build a forum of my own but have stumbled on my first problem as early as the opening page. To the problem: I want to show a simple forum layout...
1
by: rosie2006 | last post by:
Environment: .net2.0 over oracle Problem? a simple select statement within a DetailsView that gets two parameter values from a GridView SelectedValue. It might be valuable to understand that to...
17
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.