ulteriormotif
Technical User
The query below is used to bring my blocks and sub-blocks (of land) together, and define the season I want to look at, and is a base query for another query.
SELECT [DAT - Blocks].[Property ID], [DAT - Blocks].[Block ID], [DAT - Block Sub-blocks].[SubBlock ID], (select [currentyear] from [BAS - current year]) AS Currentseason
FROM [DAT - Blocks] LEFT JOIN [DAT - Block Sub-blocks] ON [DAT - Blocks].[Block ID] = [DAT - Block Sub-blocks].tBlockID;
The Currentyear table only has one record in it ever - it's a single record holding table that's used to control pretty much the whole database - the user can change the current year at various points and that limits all queries, input screens, etc, appropriately.
The query above runs fine on its own, but when I use it in subsequent queries, they either don’t run, or they do run but then throw the following error when I try to close the query.
"This action will reset the current code in break mode
Do you want to stop running the code?
To halt the execution of the program so the Module window can be closed, select Yes.
To leave the code in the current state, select No. "
The rest of the database then goes screwy and the above error appears when I’m running unrelated queries or trying to close forms, etc (the common denominator seems to be it happening on closing something). I have to close the database and reopen to go any further.
Example of subsequent query that throws the error:
SELECT [U - blocks subblocks currentseason].[Property ID], [U - blocks subblocks currentseason].[Block ID], [U - blocks subblocks currentseason].[SubBlock ID], [U - blocks subblocks currentseason].Currentseason, [DAT - production targets].blockid, IIf([dat - production targets]![blockid] Is Null,"NO","yes") AS [Target set]
FROM [U - blocks subblocks currentseason] LEFT JOIN [DAT - production targets] ON ([U - blocks subblocks currentseason].[SubBlock ID] = [DAT - production targets].blockid) AND ([U - blocks subblocks currentseason].Currentseason = [DAT - production targets].Season);
It does all seem to go back to the subquery. Can anyone give me a pointer on where I’m going wrong?