dearlandlord88
New member
- Local time
- Today, 04:11
- Joined
- Feb 25, 2015
- Messages
- 5
Hello all.
Hoping someone may be able to help with an error I keep getting with the syntax of an update query I'm putting together. I'm sure it's an embarrassingly basic mistake I'm making, but I'm fairly new to Access and can't seem to find a solution. Have searched this and other forums for answers to similar questions but still can't resolve.
I have an update query that updates a table containing students' test results. The original SQL, which predates when I first took over managing this database is as follows:
That's just an excerpt; it goes on much longer because there are around 20 fields, but obviously the syntax of the '[tbl_*ModuleGrades_Yr1].[Mod2 Prelim A] = [tbl_Assessmentyr1].[Mod2 Prelim A]' section just repeats with different field names, separated by commas
The problem with this is that the table containing the updates [tbl_Assessmentyr1] is a record of only new grades achieved within a recent time period. Therefore it will contain blanks in some fields where a student may already have a grade recorded in the main table [tbl_*ModuleGrades_Yr1] because they took that particular test in a previous time period. So you could easily overwrite valid results with blanks.
To fix this I tried to amend the syntax so that will only make updates where the field in the main table does not already contain a result. I used the following:
That works fine if my statement deals with just a single field, but if I do this for all 20 fields that the statement originally covered, i.e. so it reads like this...
...and so on I get 'syntax error: comma in query statement'. There were no such problems before, so I assume the problem lies in the syntax of the WHERE part of the statement that I've added, but I can't figure out where I've gone wrong.
Very grateful for any assistance.
Hoping someone may be able to help with an error I keep getting with the syntax of an update query I'm putting together. I'm sure it's an embarrassingly basic mistake I'm making, but I'm fairly new to Access and can't seem to find a solution. Have searched this and other forums for answers to similar questions but still can't resolve.
I have an update query that updates a table containing students' test results. The original SQL, which predates when I first took over managing this database is as follows:
UPDATE [tbl_Assessmentyr1] INNER JOIN [tbl_*ModuleGrades_Yr1] ON [tbl_Assessmentyr1].[Student ID] = [tbl_*ModuleGrades_Yr1].[Student ID] SET [tbl_*ModuleGrades_Yr1].[Student ID] = [tbl_Assessmentyr1].[Student ID], [tbl_*ModuleGrades_Yr1].[Mod1 Prelim A] = [tbl_Assessmentyr1].[Mod1 Prelim A],[tbl_*ModuleGrades_Yr1].[Mod2 Prelim A] = [tbl_Assessmentyr1].[Mod2 Prelim A]
That's just an excerpt; it goes on much longer because there are around 20 fields, but obviously the syntax of the '[tbl_*ModuleGrades_Yr1].[Mod2 Prelim A] = [tbl_Assessmentyr1].[Mod2 Prelim A]' section just repeats with different field names, separated by commas
The problem with this is that the table containing the updates [tbl_Assessmentyr1] is a record of only new grades achieved within a recent time period. Therefore it will contain blanks in some fields where a student may already have a grade recorded in the main table [tbl_*ModuleGrades_Yr1] because they took that particular test in a previous time period. So you could easily overwrite valid results with blanks.
To fix this I tried to amend the syntax so that will only make updates where the field in the main table does not already contain a result. I used the following:
UPDATE [tbl_Assessmentyr1] INNER JOIN [tbl_*ModuleGrades_Yr1] ON [tbl_Assessmentyr1].[Student ID] = [tbl_*ModuleGrades_Yr1].[Student ID] SET [tbl_*ModuleGrades_Yr1].[Mod1 Prelim A] = [tbl_Assessmentyr1].[Mod1 Prelim A] WHERE [tbl_*ModuleGrades_Yr1].[Mod1 Prelim A] is Null
That works fine if my statement deals with just a single field, but if I do this for all 20 fields that the statement originally covered, i.e. so it reads like this...
UPDATE [tbl_Assessmentyr1] INNER JOIN [tbl_*ModuleGrades_Yr1] ON [tbl_Assessmentyr1].[Student ID] = [tbl_*ModuleGrades_Yr1].[Student ID] SET [tbl_*ModuleGrades_Yr1].[Student ID] = [tbl_Assessmentyr1].[Student ID], [tbl_*ModuleGrades_Yr1].[Mod1 Prelim A] = [tbl_Assessmentyr1].[Mod1 Prelim A] WHERE [tbl_*ModuleGrades_Yr1].[Mod1 Prelim A] is Null, [tbl_*ModuleGrades_Yr1].[Mod2 Prelim A] = [tbl_Assessmentyr1].[Mod2 Prelim A] WHERE [tbl_*ModuleGrades_Yr1].[Mod2 Prelim A] is Null, [tbl_*ModuleGrades_Yr1].[Mod3 Prelim A] = [tbl_Assessmentyr1].[Mod3 Prelim A] WHERE [tbl_*ModuleGrades_Yr1].[Mod3 Prelim A] is Null
...and so on I get 'syntax error: comma in query statement'. There were no such problems before, so I assume the problem lies in the syntax of the WHERE part of the statement that I've added, but I can't figure out where I've gone wrong.
Very grateful for any assistance.
Last edited: