Avatar billede nyholm Novice
18. september 2005 - 17:15 Der er 11 kommentarer og
1 løsning

Transform a question into code

In creating a new record in a table I have several hidden forms, from which I collect data. Now I want to minimize the nbr of forms and collect the data through code. In one example the datasource is: SELECT NZ(Sum(Resapost.TAXAMETERBELOPP),0) AS SummaförTAXAMETERBELOPP FROM Resapost WHERE (((Resapost.SlutDat) Between Forms.PassOverfor1.Startdat And Forms.PassOverfor1.Slutdat) And ((Resapost.TAXINR)=Forms.PassOverfor1.TAXINR) And ((Resapost.ARBPASSNR)=Forms.PassOverfor1.ARBPASSNR) And ((Resapost.KREDITTYP)=999));.
How should the code be written to give the same?
Avatar billede terry Ekspert
18. september 2005 - 17:25 #1
Hi Nyholm, hope the last dB I sent works as required.

Can you explain what you meen by "collect ther data through code"?

Do yo want to be able to enter the criteria directly into the SQL? Maybe you could use the inputbox for this.
Avatar billede nyholm Novice
18. september 2005 - 18:37 #2
After importing data to two different tables, Pass and Resapost, I will lookup info from thees tables and create records in another table, Grund.
To one record in Pass there are several records in Resapost which are detalj information obout the record in Pass. I have to combine these two to get the complete information. The same info in both tables are Taxinr, Arbpassnr, Forarid. This is the identification of a specific taxicar, the id of the shift and the id of the driver. In Pass I get the date and time of the shifts beginning and end and the total income from the shift. In Resapost I have detalj info about each and every receipt from the terminal in the car. One of the problems is that there is'nt one exclusive id of a shift. A shift from two different cars can have the same id. Due to this, Taxinr, Arbpassnr and Forarid must be the same in both tables to be absolute sure that I do'nt get false data. In the table Grund I'm creating new shift info with a summary of the detalj info from Resapost. I should also metion that in Resapost the date and time is for the beginning and end of eath and every receipt, but in Pass it is when the driver loged on and out from the shift. To gather the info I'm now using several hidden forms from which I'm collecting data to the form attached to the table Grund.
There You have the background.
Avatar billede terry Ekspert
18. september 2005 - 18:56 #3
If you make a query where you JOIN on the three fields representing a unique key, cant you find the information you want?
Avatar billede terry Ekspert
18. september 2005 - 18:58 #4
add both the tables to a query and just join the fields using drag and drop. This will give you an INNER JOIN which means that there must be information from BOTH tables before they are shown in the result.
Avatar billede terry Ekspert
18. september 2005 - 19:12 #5
Once you have the basic query in place you can then begin to GROUP and sum as in your example query
Avatar billede nyholm Novice
18. september 2005 - 20:25 #6
The hidden forms I'm using works as questions and the result is transfered from these forms to one form. I would like to get the same info without opening the hidden forms. Creating the new records in the table Grund is done automaticly from a button on the form attached to Grund. This process is, I belive, is unneccessary slow since several hidden forms has to open and then close after the data of one shift is collected. Then opend again for the next shift and so on. I think there must be an easier way to go.
Avatar billede terry Ekspert
19. september 2005 - 09:35 #7
I think its going to be necessary to see the dB so that I fully understand your requirement. If you can send it with an explanation as to how thing currently work then perhaps I can make some suggestins. I'll take a look this evening, busy right now :o)
Avatar billede nyholm Novice
19. september 2005 - 17:08 #8
The db has been sent
Avatar billede terry Ekspert
19. september 2005 - 19:15 #9
Hi Nyholm
I have receive it and hope to get time to look at it this evening.
Avatar billede nyholm Novice
19. september 2005 - 22:20 #10
Than You for Your comments!
Why does'nt the box appear where I can pick Your name and accept the answer?
Avatar billede terry Ekspert
20. september 2005 - 09:14 #11
Need to place an answer :o)
Avatar billede terry Ekspert
20. september 2005 - 17:54 #12
tak
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