Avatar billede jadr Nybegynder
04. juli 2007 - 11:55 Der er 17 kommentarer

Obligatorisk felt i subformular, hvordan ?

Hej

Jeg har en formular med en underfomular. Én af felterne i underfomularen er obligatorisk, men Posten kan sagtens gemmes uden indhold i feltet, hvorfor ? Jeg har brug for at formularen og underformularen ikke kan gemmes unden indhold i flere felter, blandt andet et vigtigt felt i underformularen.

Jeg har sat det til obligatorisk, men ingen forskel.

Mvh
Jakob
Avatar billede terry Ekspert
04. juli 2007 - 14:22 #1
make sure that the field in the table which the field comes from has its "Required" property set to yes. And also that the "Default Value" is empty.
Avatar billede jadr Nybegynder
05. juli 2007 - 08:59 #2
Nope, doesn't work. I've searched high and low, from what I've read it's not possible. I've set the required and default value as you said, no luck. It seems, that, since it's a subform, Access saves the post before I even enter the subform. And thus, I can exit the post without data in the subform.
Avatar billede terry Ekspert
05. juli 2007 - 09:19 #3
Maybe I havent quite understood the problem.

A field which is "obligatorisk" is only valid when you create/change a record in that table. If you have a main form and add a record there it doesnt mean that you have automatically added a record to the sub form table.

Is it possible to see the database?
ekspertenATsanthell.dk

AT = @
Avatar billede jadr Nybegynder
05. juli 2007 - 09:47 #4
Can't show you the db, sorry. Perhaps I could do a little cheat. Could I, when a new post is created, enter invalid data ind the subform, then when the user wants to create a new post, the invalid data creates an event ? get my point ?
Avatar billede terry Ekspert
05. juli 2007 - 10:20 #5
To decide on a solution all depends on what the applications is supposed to do.
For example should it be allowed to add a record in the main form without any related records in the sub form?

If there are no records in the sub form should the user be asked if they have forgotten to to add and if so go back and add one or more. Or should they be allowed to procede without adding records in the sub form and at the same time delete the record in the main form. As you can see there are a number of ways to do things and in the end it is up to you.

You can test if there are any records in the sub form with code similar to this

If Me.SubFormObject.Form.Recordset.RecordCount = 0 Then ....


NOTE: SubFormObject is the name of the object containing the sub form NOT the name of the sub form. In most cases they are named the same but they need not be.
Avatar billede jadr Nybegynder
05. juli 2007 - 11:57 #6
Can't make that sentence work.

Your note... the SubFormObject, is that the form, the field or ?

Would it be (the field):
If Me.boks_Lånenummerfelt.Form.Recordset.RecordCount = 0 Then ....

Or would it be (the form):
If Me.Form_Rabatudbetaling.Form.Recordset.RecordCount = 0 Then ....

Cheers
Avatar billede terry Ekspert
05. juli 2007 - 13:01 #7
it could be Form_Rabatudbetaling but it doesnt need to be.

In design view click in the very edge of the sub form then righ click and choose properties. On the top of the properties window you should see Subform/Subreport and the name. If you see Form then you havent selected the Subform/Subreport. Once you have selected the Subform/Subreport then you need to replace SubFormObject with the name.

The name of the Subform/Subreport ane the actual from are very likely the same but as I said they do not need to be.
Avatar billede jadr Nybegynder
05. juli 2007 - 13:39 #8
made it work ;) thx again
jakob
Avatar billede terry Ekspert
05. juli 2007 - 13:46 #9
your welcome. You need to accept one of the answer to close the question, this one too http://www.eksperten.dk/spm/775807 :o)
Avatar billede jadr Nybegynder
05. juli 2007 - 13:49 #10
Hey Terry

I think I have, several times ? Why does this accepting always trick me somehow ?
Jakob
Avatar billede terry Ekspert
05. juli 2007 - 13:58 #11
I dont often place questions so not too sure how it works but I think you need to select a user from the list of those who have placed an answer then accept.
Avatar billede terry Ekspert
05. juli 2007 - 13:58 #12
I dont think it works so good
Avatar billede jadr Nybegynder
05. juli 2007 - 14:02 #13
me neither, i've pressed that silly button so many times now.
Avatar billede terry Ekspert
05. juli 2007 - 14:06 #14
Avatar billede jadr Nybegynder
23. juli 2007 - 08:13 #15
tried once again :)
Avatar billede terry Ekspert
23. juli 2007 - 08:32 #16
Strange. Maybe you could place an answer yourself and see if it makes a difference. And if not then I'm not going to lose any sleep over 30 points :o)
Avatar billede terry Ekspert
23. juli 2007 - 08:35 #17
You could try here too, but I can see youhave no problems with other questions.
http://www.eksperten.dk/spm/775807

Other users have compained about it not working so good, so maybe you should contact admin.
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