Avatar billede burkal Nybegynder
06. oktober 2003 - 18:58 Der er 31 kommentarer og
1 løsning

Felt betingelser

Hej
Jeg har en tabel med 4 kolloner:
Tal1    Tal2  Tal3  Tal4

Jeg vil godt have at tal1 bliver autoudfyldt udfra forholdet mellem tal3 ogtal4.
F.eks.
Hvis tal3>tal4 er tal1 = 3
Hvis tal3<tal4 er tal1 = 0
Hvis tal3=tal4 er tal1 = 1

Hvordan går jeg det lettest?
Avatar billede terry Ekspert
06. oktober 2003 - 19:13 #1
The only way you can do this is if you enter the data through a form

In the before update event on the form

If tal3>tal4 then tal1 = 3
Else
if tal3<tal4  Then tal1 = 0

else
tal1 = 1

endif
endif
Avatar billede terry Ekspert
06. oktober 2003 - 19:14 #2
But WHY have an extra field in the form? You can make a query which calculates tal1!
Avatar billede Slettet bruger
06. oktober 2003 - 19:16 #3
det har du vel selv skrevet:
(lavet i asp)


if tal3>tal4 then
tal1 = 3
end if
if tal3<tal4 then
tal1 = 0
end if
if tal3=tal4 then
tal1 = 1
end if

SQL = "insert into tabel(tal1,tal2,tal3,tal4) values(" & tal1 &"," & tal2 &"," & tal3 &"," & tal4 &")")
Avatar billede terry Ekspert
06. oktober 2003 - 19:20 #4
I dont see any mention of ASP in the question!
Avatar billede burkal Nybegynder
06. oktober 2003 - 19:21 #5
Jeg har arbejdet en del med excel og der kan man bare skrive en IF-sætning i feltet og det håbede jeg også man kunne i Access.

Jeg vil ikke bruge forms endnu. jeg bruger kollonerne tal1 og tal2 i forespørgsler.
Avatar billede Slettet bruger
06. oktober 2003 - 19:23 #6
terry>> nej det har du ret i... men et eller andet sprog skal man vel bruge til det... kan ikke se, hvordan man skal gøre i ren sql.
Avatar billede burkal Nybegynder
06. oktober 2003 - 19:25 #7
Er der ike en indbygget facilitet i access?
Avatar billede terry Ekspert
06. oktober 2003 - 19:37 #8
the example I gave is in VBA (in Access)
Avatar billede terry Ekspert
06. oktober 2003 - 19:41 #9
If you are using ASP as the user interface then you can use VBScript or something and then do it directly in SQL as kvadratrodenaf1 shows. You will also very likley need an update too!

But lets find out where you are entering the data first?
Avatar billede burkal Nybegynder
06. oktober 2003 - 19:55 #10
Kan man lave en join i Access?
Avatar billede terry Ekspert
06. oktober 2003 - 19:57 #11
yes, but we only have ONE table, but then ther is NOTHING stopping you JOINing the one table to itself!

But where are we going with this?
Avatar billede terry Ekspert
06. oktober 2003 - 19:59 #12
burkal>If you have worked with Excel then you should have NO problem with Access VBA. BUT you MUST enter the data through a form so that you have access to VBA. Otherwise where are we going to write IF.....
Avatar billede terry Ekspert
06. oktober 2003 - 20:00 #13
Do you have a dB?
If you send it to eksperten@santhell.dk I will makew an example using an Access form (NOT asp)!
Avatar billede burkal Nybegynder
06. oktober 2003 - 20:08 #14
original question:
I have the mentioned table, which is a table which should record soccermatch results. Column tal1 and tal2 are points earned by home- and awayteam. Tal3 and tal4 is goals for Home- and awayteam.

I want to keep the DB as simple as possible as I am new to MS Access. This DB is also meant as a learning expirience. So no forms, reports or presentationlayers if at all possible.

My question regarding Joins is because I have two queries, which makes a table with Home- and awayteam standings and it is natural to use a join to unite the two tables.
Is there a SQL-window where you can type in SQLcommands? or can you read in a txtfile with sql in access?
Avatar billede terry Ekspert
06. oktober 2003 - 20:14 #15
In Access you should see a button (icon) named Queries on the database window. Press this button an dthen at the top of the database window press New.
Now you get a dialog where you can choose from differmet types of queries, select Design View (the top one).

Now you can choose which tables you want to use, and if you press close without chooseing any tables you can then enter the SQL directly. Right click on the title bar of the query window and choose SQL view from the menu. Or choose SQL from th emain menu.
Avatar billede terry Ekspert
06. oktober 2003 - 20:14 #16
I understand danish perfectly
Avatar billede burkal Nybegynder
06. oktober 2003 - 20:18 #17
Jubii sqlvindue.

jeg vil godt se en form på min DB, så hvis du har tid vil jeg gerne sende min DB til dig.

Er det ok?
Avatar billede terry Ekspert
06. oktober 2003 - 20:19 #18
In Access you can NOT enter a new record and set the value of a third field from the values you enter form the first two fiels! You will need to run an update query AFTER you enter a new record.

In your table you only need to record the goals scored, then in an SQL statement you can calculate the values of the other fields
Avatar billede terry Ekspert
06. oktober 2003 - 20:21 #19
send away
Avatar billede terry Ekspert
06. oktober 2003 - 20:23 #20
burkal>If you rnew to Access I suggest you get hold of a book, and there is also a link you may get help from here.

http://www.hedeskov.dk/
Avatar billede burkal Nybegynder
06. oktober 2003 - 20:24 #21
Den er sendt
Avatar billede terry Ekspert
06. oktober 2003 - 20:26 #22
har fået den
Avatar billede terry Ekspert
06. oktober 2003 - 21:06 #23
Avatar billede terry Ekspert
06. oktober 2003 - 21:10 #24
I sent the dB but I got an error so I have now tried with another account
Avatar billede burkal Nybegynder
06. oktober 2003 - 21:10 #25
jeg har kigget på den. Jeg har købt et par hæfter. har du sendt noget tilbage?
Avatar billede burkal Nybegynder
06. oktober 2003 - 21:11 #26
Hvor stor (KB) er DB?
Avatar billede terry Ekspert
06. oktober 2003 - 21:13 #27
The error is
Unknown user: bjarne_burkal@hotmail.com

one of my mail accounts seems to be having a problem with certain addresses!
Avatar billede terry Ekspert
06. oktober 2003 - 21:13 #28
Oops, sorry, shouldnt have pasted that here!
Avatar billede terry Ekspert
06. oktober 2003 - 21:16 #29
I'm off for 15 minutes!
Avatar billede terry Ekspert
06. oktober 2003 - 21:37 #30
have you received anything?
Avatar billede burkal Nybegynder
06. oktober 2003 - 21:42 #31
yes, jeg har modtaget det. Det ser jo meget nemt ud. ;o) Jeg tror jeg skal ha lavet db så simpel som muligt inden jeg begynder med forms. Men tak fordi du viste mig det. Jeg tror jeg stopper for idag. Så du skal have mange tak.
Avatar billede terry Ekspert
06. oktober 2003 - 21:46 #32
selv tak

Nat :o)
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