12. februar 2005 - 14:11
Der er
53 kommentarer og 1 løsning
amatør spørgesmål sql sætning hjælp ?
jeg har lavet noget i access og har noget kodning i vb. når jeg trykker på knappen i access kalder den en procedure som indholder en strSQl og den melder hele tiden med fejl. fejl beskrivelse := Run-time error ’3061’ der er for få parameter, der er ventet et udpluk kunne se sådan ud: Private Sub aktiver (land As String) Dim buf As Byte Dim dbs As Database Dim qry, qms As QueryDef Dim rec, rms, rtmp As Recordset Dim filnavn, strSQL, tmp As String Dim nStep, maxW, step, wi, PrøveID, cntK, cntS, RetVal As Integer Dim gnsK, gnsS As Double strSQL = "SELECT Salg.Ordrenummer AS Salg_Ordrenummer, Salg.Sagsansvarlig, " & _ " Salg.Startdato, Salg.Slutdato, Salg.Rapportnr, Salg.Projektnr, " & _ " Salg.Rekvirent, Salg.Kontaktperson, Salg.Rapportmodt, Salg.Kontaktmodt, " & _ " Salg.[Antal biler], Salg.Svarmulighed, Salg.Ekstra, Biler.Provenr AS Prøvenr, " & _ " Biler.Ordrenummer AS Biler_Ordrenummer, Biler.Prove, Biler.Materiale, " & _ " Biler.farve, Biler.Storelse, Biler.Periode, Biler.Anv " & _ " FROM Salg INNER JOIN Biler ON Salg.Ordrenummer = Biler.Ordrenummer " & _ " WHERE ((Salg_Ordrenummer)=" & Forms![Salg]![BilerSubForm].Form![Ordrenummer] & ")" Set qry = dbs.CreateQueryDef("", strSQL) Set rec = qry.OpenRecordset() (den melder fejl her med Run-time error ’3061’ der er for få parameter, der er ventet 1) rec.MoveFirst PrøveID = rec.Fields![ Salg_Ordrenummer] filnavn = rec.Fields![Biler.Ordrenummer] & "-" & rec.Fields![Prøvenr] & "-" & land & ".xml" On Error Resume Next Og koden forsætter de rude af ……. ………………………… jeg har efter hånden prøvet alt uden held. strSQL virker hvis jeg ikke bruger den sidste linje som er nødvendigt. er der ikke nogen der gider at hjælpe :(
Annonceindlæg fra Barco
12. februar 2005 - 14:19
#1
den melder først fejl når denne sætning kommer med " WHERE ((Salg_Ordrenummer)=" & Forms![Salg]![BilerSubForm].Form![Ordrenummer] & ")"
12. februar 2005 - 14:19
#2
try strSQL = "SELECT Salg.Ordrenummer AS Salg_Ordrenummer, Salg.Sagsansvarlig, " & _ " Salg.Startdato, Salg.Slutdato, Salg.Rapportnr, Salg.Projektnr, " & _ " Salg.Rekvirent, Salg.Kontaktperson, Salg.Rapportmodt, Salg.Kontaktmodt, " & _ " Salg.[Antal biler], Salg.Svarmulighed, Salg.Ekstra, Biler.Provenr AS Prøvenr, " & _ " Biler.Ordrenummer AS Biler_Ordrenummer, Biler.Prove, Biler.Materiale, " & _ " Biler.farve, Biler.Storelse, Biler.Periode, Biler.Anv " & _ " FROM Salg INNER JOIN Biler ON Salg.Ordrenummer = Biler.Ordrenummer " & _ " WHERE ((Salg_Ordrenummer)= '" & Forms![Salg]![BilerSubForm].Form![Ordrenummer] & "')"
12. februar 2005 - 14:20
#3
If Salg_Ordrenummer is a text field then it must be enclose in ''
12. februar 2005 - 14:21
#4
Salg_Ordrenummer is a text how enclose
12. februar 2005 - 14:22
#5
what did you change ?
12. februar 2005 - 14:25
#6
'" & Forms![Salg]![BilerSubForm].Form![Ordrenummer] & "')" NOTICE ' at start and end
12. februar 2005 - 14:26
#7
it says "sub og function not defined !" den melder en anden fejl
12. februar 2005 - 14:26
#8
so when it gets translated to SQL it will look like this (EXAMPLE) ....WHERE ((Salg_Ordrenummer)= 'ABCD1234') and not ....WHERE ((Salg_Ordrenummer)= ABCD1234)
12. februar 2005 - 14:27
#9
if you are still having problems I can take a look for you eksperten@NOSPAMsanthell.dk remove NOSPAM
12. februar 2005 - 14:29
#10
syntaxt error
12. februar 2005 - 14:31
#11
can you send the dB?
12. februar 2005 - 14:34
#12
whish i could, its from my work and i have signed that its confident...
12. februar 2005 - 14:37
#13
it says runtime error 3075 there is a syntaxt error in the string query "((salg_Ordrernummer)=3434')".
12. februar 2005 - 14:38
#14
I assume we are talking Access? Try displaying th etransalted SQL in the debug window Ctrl+G then ?strSQL then copy the SQL into a new query and see if you can find teh problem there
12. februar 2005 - 14:40
#15
12/02-2005 14:37:52 "((salg_Ordrernummer)=3434')". This tells me that you have NOT placed a ' at the front of the string MOTICE the ' before " WHERE ((Salg_Ordrenummer)= ' "
12. februar 2005 - 14:40
#16
MOTICE = NOTICE
12. februar 2005 - 14:43
#17
how copy new sql ?
12. februar 2005 - 14:45
#18
ok, now i get my old error back "Run-time error ’3061’ der er for få parameter" in the code : Set rec = qry.OpenRecordset() 'it stops here and says "Run-time error ’3061’ der er for få parameter"
12. februar 2005 - 14:47
#19
whitout this line my sql is working " WHERE ((Salg_Ordrenummer)='" & Forms![Salg]![BilerSubForm].Form![Ordrenummer] & "')"
12. februar 2005 - 14:48
#20
have you tried displaying the SQL in the debug window and thencopyin this to a new query?
12. februar 2005 - 14:49
#21
is it possible to make a dB containing only what I need to look at it?
12. februar 2005 - 14:49
#22
it is a funtcion that export the thing im seen on the form but when the last line isnt there it always takes the first record
12. februar 2005 - 14:50
#23
what wil this help ? 12/02-2005 14:48:30
12. februar 2005 - 14:53
#24
just copy and then copy back ?
12. februar 2005 - 14:54
#25
It will show you the FULL SQL after it has been converted to a string. Then you can cut and paste this into a query wher it should be NUCH easier to see if there is an error in the SQL
12. februar 2005 - 14:55
#26
Make a new query and then copy the SQL into this
12. februar 2005 - 14:58
#27
is it msgBox strSQL i should write and the run the program and then use the message ?
12. februar 2005 - 15:01
#28
No Press Ctrl+G This opens the debug window in VBA(code) then write ?strSQL followed by enter(return) Now you will see the SQL which is used in qry
12. februar 2005 - 15:04
#29
I als noticed something else, which has nothing to do with this error though. Dim qry, qms As QueryDef THis on defines qms as a QueryDef, qry will be a variant data type! The correct way is Dim qry as QueryDef, qms As QueryDef But as I said it has nothing to do with this problem and would still work, variant data types are just bigger
12. februar 2005 - 15:09
#30
i write msgBox strSQL in the editor, then i got af message which says : SELECT Salg.Ordrenummer AS Irdrer_Ordrenummer, Salg.Sagsansvarlig, Salg.Startdato, Salg.Slutdato, Salg,Rapportnr, Salg.Projektnr, Salg.Rekvirent, Salg.Kontaktperson, Salg.Rapportmodt, Salg.Kontaktmodt, Salg[Antal biler], Salg.Svarmulighed, Salg.Ekstra, Prøve.Provenr AS Prøvenr, Biler.Ordrenummer AS Biler_Ordrenummer, Biler.Prover, Biler.Storelse , Biler.Udtagning, Biler.Metode, Biler.Periode, Biler.Vedanv FROM Salg INNER Join Biler ON Salg.Ordrenummer =Biler.Ordrenummer WHERE ((Salg_Ordrenummer)='3434')
12. februar 2005 - 15:11
#31
Now you can copy this to an Access Query (make a new query the same palce you make tables)
12. februar 2005 - 15:12
#32
and when im putting this into the ctrl+g it says: Compile error: Expected: end of statement
12. februar 2005 - 15:13
#33
OK I think I know what the problem is! Change WHERE ((Salg_Ordrenummer)= to WHERE ((Salg.Ordrenummer)=
12. februar 2005 - 15:15
#34
ok, i tryit but it says : There is a syntaxt error, because its missin a operator. in the query "Salg[Antal biler]".
12. februar 2005 - 15:16
#35
From your comment 12/02-2005 15:09:20 THis looks strange!! vv SELECT Salg.Ordrenummer AS Irdrer_Ordrenummer,
12. februar 2005 - 15:16
#36
Irdrer?
12. februar 2005 - 15:18
#37
i corectet now it makes no difrent :(
12. februar 2005 - 15:22
#38
It would be MUCH easier if you can send me the dB. Can you make a copy of only what I need and remove the data I dont need to see
12. februar 2005 - 15:25
#39
ok i change this WHERE ((Salg_Ordrenummer)= to WHERE ((Salg.Ordrenummer)= and it says : Run-time error '3464' Datatyperne stemmer ikke overens i kriterieudtrykket english : Datatypes dosent match the query....
12. februar 2005 - 15:27
#40
!!! You did say that Salg.Ordrenummer was text? I think you should try strSQL = "SELECT Salg.Ordrenummer AS Salg_Ordrenummer, Salg.Sagsansvarlig, " & _ " Salg.Startdato, Salg.Slutdato, Salg.Rapportnr, Salg.Projektnr, " & _ " Salg.Rekvirent, Salg.Kontaktperson, Salg.Rapportmodt, Salg.Kontaktmodt, " & _ " Salg.[Antal biler], Salg.Svarmulighed, Salg.Ekstra, Biler.Provenr AS Prøvenr, " & _ " Biler.Ordrenummer AS Biler_Ordrenummer, Biler.Prove, Biler.Materiale, " & _ " Biler.farve, Biler.Storelse, Biler.Periode, Biler.Anv " & _ " FROM Salg INNER JOIN Biler ON Salg.Ordrenummer = Biler.Ordrenummer " & _ " WHERE ((Salg.Ordrenummer)=" & Forms![Salg]![BilerSubForm].Form![Ordrenummer] & ")"
12. februar 2005 - 15:29
#41
i have write all the thing that im allowed to show, i wish just i could send it , but i have signed paper to not do it, its not about the data but codes there are inside, its connect whit the system for the company and it will be wrong , i know that you just want to help me but i swoverd that i wouldent do it
12. februar 2005 - 15:30
#42
:(
12. februar 2005 - 15:32
#43
what data type does Salg.Ordrenummer have in the table?
12. februar 2005 - 15:33
#44
its a nummber and also biler.Ordrenummer is number
12. februar 2005 - 15:36
#45
OK then try the code I placed at 12/02-2005 15:27:51 this expects a number as Salg.Ordrenummer
12. februar 2005 - 15:40
#46
is this only the difrent from the origin " WHERE ((Salg.Ordrenummer)=" & Forms![Salg]![BilerSubForm].Form![Ordrenummer] & ")"
12. februar 2005 - 15:41
#47
yes
12. februar 2005 - 15:44
#48
It says now the element couldent be found filnavn = rec.Fields![Bil.Ordrenummer] & "-" & rec.Fields![Prøvenr] & "-" & land & ".xml"
12. februar 2005 - 15:45
#49
sorry it is filnavn = rec.Fields![Biler.Ordrenummer] & "-" & rec.Fields![Prøvenr] & "-" & land & ".xml"
12. februar 2005 - 15:48
#50
i change it to filnavn = rec.Fields![Biler_Ordrenummer] & "-" & rec.Fields![Prøvenr] & "-" & land & ".xml" and it works fine now and you have help my so much and i hope that good wil make one of you wishes true thanky thanky :) :) :)
12. februar 2005 - 15:52
#51
so we have new found the correct SQL? Make sure you use the correct names!! Rec!Biler_Ordrenummer
12. februar 2005 - 16:00
#52
When you use ALIAS names in your SQL (SELECT Salg.Ordrenummer AS Salg_Ordrenummer ...) then you must use Salg_Ordrenummer in the recordset
12. februar 2005 - 16:01
#53
Great! Have a good weekend and thanks! Terry
12. februar 2005 - 17:23
#54
you 2
Kurser inden for grundlæggende programmering