UPDATE SQL Problem

D

DS

I Have an update query that is updateing one table called MenuInfo...the
problem is that part of the criteria is based on a second table
MenuDetails. The two tables are joined on MenuID...the problem is that
it's not increasing the ModGroupLevel1 field by 1.

Dim LevelUpSQL As String
DoCmd.SetWarnings False
LevelUpSQL = "UPDATE MenuInfo LEFT JOIN MenuInfo ON MenuDetails.MenuID =
MenuInfo.MenuID SET MenuInfo.ModGroupLevel1 = MenuInfo.ModGroupLevel1 +
1 " & _
"WHERE (((MenuDetails.TerminalID)=[Forms]![MenuCreator]![TxtStation]) " & _
"AND ((MenuInfo.MenuID)=[Forms]![MenuCreator]![TxtMenu]) " & _
"AND ((MenuInfo.PriceID)=[Forms]![MenuCreator]![TxtPriceID]) " & _
"AND ((MenuInfo.MenuCatID)=[Forms]![MenuCreator]![TxtSection]) " & _
"AND ((MenuInfo.ItemID)=[Forms]![MenuCreator]![TxtItem]) " & _
"AND ((MenuInfo.ModGroup1)=[Forms]![MenuCreator]![TxtModGroup]));"
DoCmd.RunSQL (LevelUpSQL)
DoCmd.SetWarnings True
Me.ListGroups.Requery
 
J

John Vinson

I Have an update query that is updateing one table called MenuInfo...the
problem is that part of the criteria is based on a second table
MenuDetails. The two tables are joined on MenuID...the problem is that
it's not increasing the ModGroupLevel1 field by 1.

Dim LevelUpSQL As String
DoCmd.SetWarnings False
LevelUpSQL = "UPDATE MenuInfo LEFT JOIN MenuInfo ON MenuDetails.MenuID =
MenuInfo.MenuID SET MenuInfo.ModGroupLevel1 = MenuInfo.ModGroupLevel1 +
1 " & _
"WHERE (((MenuDetails.TerminalID)=[Forms]![MenuCreator]![TxtStation]) " & _
"AND ((MenuInfo.MenuID)=[Forms]![MenuCreator]![TxtMenu]) " & _
"AND ((MenuInfo.PriceID)=[Forms]![MenuCreator]![TxtPriceID]) " & _
"AND ((MenuInfo.MenuCatID)=[Forms]![MenuCreator]![TxtSection]) " & _
"AND ((MenuInfo.ItemID)=[Forms]![MenuCreator]![TxtItem]) " & _
"AND ((MenuInfo.ModGroup1)=[Forms]![MenuCreator]![TxtModGroup]));"
DoCmd.RunSQL (LevelUpSQL)
DoCmd.SetWarnings True
Me.ListGroups.Requery

Your query is joining MenuInfo to MenuInfo and not including the
MenuDetails table - shouldn't the start of the query be

LevelUpSQL = "UPDATE MenuInfo LEFT JOIN MenuDetails ON
MenuDetails.MenuID = MenuInfo.MenuID...


John W. Vinson[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

Similar Threads

Update Query Problem 2
SQL UPDATE Problem 5
SQL UPDATE on the fly 5

Top