If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
PLEASE. update access from module
Since noone has answered my question I'll try again, I bet many of you
see's my misstake. PLEASE, help me. I have written a module which is calling from a form. --------------- Function RunTheChangeBox() Const myPicture = "SELECT DISTINCT [Photos].[boxId],[Photos].[magasinId]," & _ " [Photos].[pictureId], [Photos].[magasineName],[Photos].[date], [Photos].[rowId] " & _ " FROM Photos" Dim aSql As String Dim newBox As Variant Dim oldBox As Variant Dim myMagsineName As String Dim myMagsineId As String Dim i As Integer Set db = CurrentDb() newBox = Forms![boxes]![boxId] oldBox = Forms![boxes]![oldBoxId] myMagsineName = Forms![boxes]![magasineName] myMagsineId = Forms![boxes]![magasineId] maxPicureId = DMax("pictureId", "Photos", "[magasineId] = '" & myMagsineId & "' AND [boxId] = " & oldBox & "") minPicureId = DMin("pictureId", "Photos", "[magasineId] = '" & myMagsineId & "' AND [boxId] = " & oldBox & "") i = minPicureId For i = minPicureId To maxPicureId sSQL = "Update [Photos] set [boxId] = " & newBox & " where [boxId] = " & oldBox & " AND [magasineId] = " & myMagsineId & " AND [pictureId] = " & i & " ;" CurrentDb.Execute sSQL i = i + 1 Next i Exit_RunTheChangeBox: MsgBox "Box ändrad!!!" Exit Function Err_RunTheChangeBox: MsgBox Err.description Resume Exit_RunTheChangeBox End Function When I come to ' CurrentDb.Execute sSQL ' it all crashes. Can someone pease what I've missed? Thanks in advance /Michelle A pretty desparate one after one week of struggeling and searchin for an answer |
#2
|
|||
|
|||
PLEASE. update access from module
Put the following line of code RIGHT before the
debug.print sSQL ---- put this here CurrentDb.Execute sSQL Now, run your code....let it crash....open he debug window..and you an see your sql... Try cutting and pasting one of the sql statements shown into he query builder..and run it.... Further, you could even consider posting the above resulting sql here if no errors in the syntax can be seen by your eyes... -- Albert D. Kallal (Access MVP) Edmonton, Alberta Canada |
Thread Tools | |
Display Modes | |
|
|