M
michelle
Hi folks!
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
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