Avatar billede Carlo Juniormester
05. februar 2019 - 13:40 Der er 5 kommentarer og
1 løsning

Where condition

Hej - hvis jeg skal lave en kode fra en formular til en rapport, hvor fakturanr i formularen skal følge med over i rapporten, hvordan ser where sætningen så ud?

Jeg bruger 'code builder' og nok bare glemt syntaksen.
Avatar billede terry Ekspert
05. februar 2019 - 14:08 #1
Code Builder, dont you mean Expression Builder (Right click in Criteria Field)?

If so then you should be able to Choose Field which you want to use as criteria by first finding Form and then Field
And you should end up with something like
Forms![TheForm]![TheField]
Avatar billede Carlo Juniormester
05. februar 2019 - 14:40 #2
Ok - tried it by using this code.

DoCmd.OpenReport "Invoice", acViewPreview, , [Fakturanr] = Forms![Invoice]![Fakuranr]

But got the following error "can't find the field Fakturanr referred to in your expression. The field Fakturanr is presented in both the soucing form [Invoice] and the receiving report [Invoice]. Yes form and report have the same name:-)

Thanks Terry!
Avatar billede Carlo Juniormester
05. februar 2019 - 14:52 #3
I found it!

"[Fakturanr]=" & Me.Fakturanr
Avatar billede terry Ekspert
05. februar 2019 - 15:05 #4
Great :-)
You need to be aware that this will work when the criteria is numeric, if its alphanumeric you will probably need to change it to

"[SomeAlphNumericField]= '" & Me.SomeAlphNumericField & "'"

Because the text vale has to be in 'SomeText'
Avatar billede terry Ekspert
05. februar 2019 - 15:06 #5
vale = value

Oh and dont forget to accept one of the answers so the question gets closed ;-)
Avatar billede terry Ekspert
08. februar 2019 - 09:34 #6
!
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

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