A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

PLEASE. update access from module



 
 
Thread Tools Display Modes
  #1  
Old December 19th, 2006, 08:22 PM posted to microsoft.public.access.forms
michelle
external usenet poster
 
Posts: 17
Default 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  
Old December 20th, 2006, 01:47 AM posted to microsoft.public.access.forms
Albert D. Kallal
external usenet poster
 
Posts: 2,874
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.