Skip to content
Advertisement

Increment the Prime Key Field Value Everytime Query Appends Other Fields

In my database named ‘ADMS’, there exists a table called ‘Merit’ with fields:

(Index, Merit List Number, Group, OM, AS, AR, FGEI, RFGEI, Session)

Index is the Prime Key with Data Type as ‘AutoNumber’

I want to add a new record in all field through a form named ‘Update Merit’ which has:

2 combo combo-boxes called MeritListVal and Group Val;

the rest objects are all Text Boxes which include SessVal, OMVal, ASVal, ARVal, FGEIVal, RFGEIVal, DPVal.

Now, what i want is to add new records into the table Merit through the Form ‘Update Merit’;

i tried the following SQL Code;

INSERT INTO Merit ( [Merit List Number], [Group], [OM], [AS], [AR], [FGEI], [RFGEI], [DP], [Session] )

VALUES ( [Forms]![Update Merit]![MeritListVal], [Forms]![Update Merit]![GroupVal]. [Forms]![Update Merit]![OMVal], [Forms]![Update Merit]![ASVal], [Forms]![Update Merit]![ARVal], [Forms]![Update Merit]![FGEIVal], [Forms]![Update Merit]![RFGEIVal], [Forms]![Update Merit]![DPVal] );

SELECT Merit.[Merit List Number], Merit.[Group], Merit.[OM], Merit.[AS], Merit.[AR], Merit.[FGEI], Merit.[RFGEI], Merit.[DP], Merit.[Session]

FROM Merit;

It is giving me Error: Number of Query Values and Destination Fields is not the Same.

Is it because of the PrimeGrpKey?

Is it putting an increment when the Append Query INSERTs Values into it?

If not, how to i make it increment everytime a new record is added?

What would be the SQL Code to perform this task?

Even after i deleted the Index Field it is still not adding more records, same error.

Advertisement

Answer

Your Insert Into Merit has 9 column names Your Value section has 8 column names

This is why there is a error.

enter image description here

Add another value at the “values” section of your code. My guess is “[Forms]![Update Merit]![SessionVal]”.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement