RunSQL Macro - Can't figure it out!

DanWall

Registered User.
Local time
Today, 14:43
Joined
Aug 11, 2008
Messages
78
[Resolved] - RunSQL Macro - Can't figure it out!

Hi All...

I have a subform, embedded into another form.

Main Form = frmBackloadEdit (The "backload" details - linked to tblBackloads)

Subform 1 = subfrmBackloadItems (A filtered list of items from the tblItems table, that have the tblBackload.ID field in the tblItems.Backload field.)

Subform 2 = subfrmBackloadAddItems (A list of ALL items in the tblItems table, that have nothing in the tblItems.Backload field)

BackloadDialog.jpg


I am trying to get it so when a user clicks on the ADD link of the second subform, it adds the tblBackload.ID field to the tblItems.Backload field.
I am using a MACRO, as I have been instructed explicitly to not use VBA code (for reasons I can't get into here!)

I am currently using the RunSQL command in the macro editor, however, when the user clicks the ADD link, it updates ALL the records, instead of just the one the user clicks. I believe I've used the correct syntax, however can't seem to rectify the problem.

The current SQL code in the runSQL command looks like this....


UPDATE tblItems SET tblItems.Backload = Forms![frmBackloadEdit]![ID] WHERE tblItems.ID = [ID]


I have tested the [ID] field using a msgbox, and it is returning the correct ID on the click, however it's not 'isolating' the record using the above SQL statement.....

PLEASE HELP!!!

error.jpg


Thanks,

Dan Wall.

I have attached the DB in case anyone is interested in tearing it apart. (Access 2007)
 

Attachments

Last edited:
You CAn This
UPDATE tblItems SET tblItems.Backload = Forms![frmBackloadEdit]![ID] WHERE tblItems.ID =Forms![frmBackloadEdit]![ [ID]

Enjoy
 
Thanks Backosoft, BUT, the line you have written there won't work.
It will only select the ITEMS, with the ID field the same as the BACKLOAD table's ID.

I have it figured out now....

the correct SQL should be:

UPDATE tblItems SET tblItems.Backload = Forms![frmBackloadEdit]![ID] WHERE tblItems.ID = Forms![frmBackloadEdit]![subfrmBackloadAddItems].Form![ID]

Issue solved!
 

Users who are viewing this thread

Back
Top Bottom