Avatar billede rickie Juniormester
05. januar 2007 - 10:09 Der er 14 kommentarer og
1 løsning

Update med select

Hey alle,

Er der nogen der kan hjälpe?
Jeg vil lave en SQL update men den skal også hente mere data fra en tabell.

sSQL = "UPDATE tblTemp SET tmpBeloppMånad = (SELECT VAL(SUM(COL.[UNIT_PRICE])) FROM [dbo_AMF_VW_COMMRAPP_INST] AS COL) WHERE tmpKundnummer = txtKundnummer"
DoCmd.RunSQL sSQL

Denne virker ikke men er der nogen der har en idé?
Avatar billede terry Ekspert
05. januar 2007 - 12:03 #1
try copying the SQL into a query wher it will be easier to see the problem.
I dont quite understand your WHERE. are both field sin the same table (tmpKundnummer and txtKundnummer) or is txtKundnummer maybe on a form?

If its on a form then try

sSQL = "UPDATE tblTemp SET tmpBeloppMånad = (SELECT VAL(SUM(COL.[UNIT_PRICE])) FROM [dbo_AMF_VW_COMMRAPP_INST] AS COL) WHERE tmpKundnummer = " & txtKundnummer

and if tmpKundnummer is a of type text then use

sSQL = "UPDATE tblTemp SET tmpBeloppMånad = (SELECT VAL(SUM(COL.[UNIT_PRICE])) FROM [dbo_AMF_VW_COMMRAPP_INST] AS COL) WHERE tmpKundnummer = '" & txtKundnummer & "'"
Avatar billede rickie Juniormester
10. januar 2007 - 10:02 #2
tmpKundnummer is in a form. tmpKundnummer is in the table.
When i try to execute it i get this error: Operation must use an updateble query!

Don´t know whats wrong? :-)
Avatar billede terry Ekspert
10. januar 2007 - 10:04 #3
I have an idea what the problem is (Access).

Try altering the sub select to a dsum
Avatar billede terry Ekspert
10. januar 2007 - 10:05 #4
If I remember correctly, Access doesnt like sub selects in UPDATE queries.
Avatar billede rickie Juniormester
10. januar 2007 - 10:20 #5
How can i put that into the update statement? This won´t work:
sSQL = "UPDATE tblTemp SET tmpBeloppMånad = DSUM("[UNIT_PRICE]", "[dbo_AMF_VW_COMMRAPP_INST]", "[CUSTOMER_NO]= '" & tmpKundnummer & "'")"
Avatar billede terry Ekspert
10. januar 2007 - 10:22 #6
can you send me your dB?
ekspertenATsanthell.dk

change AT to @
Avatar billede rickie Juniormester
11. januar 2007 - 09:54 #7
Have you recieved the file?
Avatar billede terry Ekspert
11. januar 2007 - 12:05 #8
no I havent receive anything.
Try
sandyATstofanet.dk
again AT = @
Avatar billede rickie Juniormester
15. januar 2007 - 13:19 #9
Sent it again :-)
Avatar billede terry Ekspert
15. januar 2007 - 20:01 #10
Hi rickie
Either you are not using the correct email address, or you have a problem with your mail server.
Normally I have no problem receiving emails, so I'm sure the problem is at your end.
Can you upload to an FTP site?
Avatar billede rickie Juniormester
16. januar 2007 - 09:02 #11
Yes i can upload to an FTP :-)
Avatar billede terry Ekspert
16. januar 2007 - 09:12 #12
I have received your dB :o)
Avatar billede terry Ekspert
16. januar 2007 - 09:26 #13
Try this
sSQL = "UPDATE tblTemp SET tmpBeloppMånad = " & DSum("[UNIT_PRICE]", "[dbo_AMF_VW_COMMRAPP_INST]", "[CUSTOMER_NO]= '" & txtKundnummer & "'")
Avatar billede rickie Juniormester
01. februar 2007 - 08:33 #14
Thanks! :-) Sorry det sene svar!
Avatar billede terry Ekspert
01. februar 2007 - 10:56 #15
thanks too
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester