Access Changing query syntax incorrectly!!!

W

W Dean

Hi,

I've written the following query which seems to work fine:

UPDATE Calender, (SELECT AccessLevel FROM Users WHERE (UserName =
[aUserName])) AS U1
SET
Calender.Approved = ((U1.AccessLevel = 1) AND ([aApproved]))
WHERE
(Calender.CalenderID = [aCalenderID])
AND
(
(Calender.UserName = [aUserName]) OR
(EXISTS(SELECT Users.UserName FROM Users WHERE
(Users.UserName=[aUserName]) AND (Users.AccessLevel=1)))
);

but after saving it and then reopening it, Access has changed the syntax:
replacing (SELECT AccessLevel FROM Users WHERE (UserName = [aUserName])) AS
U1 with [SELECT AccessLevel FROM Users WHERE (UserName = [aUserName])]. AS
U1 which causes a syntax error. Although if I just run the query without
opening it, it works fine.

Anybody know why? Is there a way to format the query so it doesn't happen.

W Dean
 
M

Michel Walsh

HI,


Try removes the [ ] around aUserName.


Hoping it may help,
Vanderghast,Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top