Avatar billede per2edb Praktikant
27. januar 2013 - 12:37 Der er 10 kommentarer og
1 løsning

Hvordan får jeg passet argumentet Id over i en sub

I Access 2007 VBA

Hvordan får jeg passet argumentet TilbudId over i en sub???

Call SearchRecord (TilbudId)

Sub (TilbudId as ????)

    DoCmd.???????.SetFocus    ' DoCmd.Subform1.SetFocus
    Docmd.TilbudId.SetFocus
    DoCmd.FindRecord TilbudId, acEntire, , acSearchAll, , acCurrent
Avatar billede terry Ekspert
27. januar 2013 - 13:27 #1
http://msdn.microsoft.com/en-us/library/aa263527(v=vs.60).aspx

Not quite sure I understand what you rtrying to do here

DoCmd.???????.SetFocus    ???
Avatar billede per2edb Praktikant
27. januar 2013 - 13:41 #2
Sorry i have a failure
Watt i want is to place this in a sub
How can i pass TilbudId????

    DoCmd.SetFocus   
    Docmd.TilbudId.SetFocus
    DoCmd.FindRecord TilbudId, acEntire, , acSearchAll, , acCurrent

---------
Call SearchRecord (TilbudId)

Sub (TilbudId as ????)

    DoCmd.SetFocus 
    Docmd.TilbudId.SetFocus
    DoCmd.FindRecord TilbudId, acEntire, , acSearchAll, , acCurrent
Avatar billede terry Ekspert
27. januar 2013 - 14:10 #3
I am assuming TilbudId is a value EG: 36

Take a look at the link I sent, this explains sending arguments to a sub/function

I still dont understand this:
Docmd.TilbudId.SetFocus

If TilbudId is a value EG: 36
then that would equate to

Docmd.36.SetFocus
Avatar billede terry Ekspert
27. januar 2013 - 14:23 #4
I'm guessing that you want to use both the name of the field and also the value.

So try passing the name of the field as a string


and then you could use (not tested)

Me(NameOfField).setfocus
DoCmd.FindRecord NameOfField, acEntire, , acSearchAll, , acCurrent
Avatar billede terry Ekspert
27. januar 2013 - 14:24 #5
DoCmd.FindRecord Me(NameOfField), acEntire, , acSearchAll, , acCurrent
Avatar billede per2edb Praktikant
27. januar 2013 - 14:28 #6
I will explane

I want to place this in a sub:

    DoCmd.SetFocus   
    Docmd.TilbudId.SetFocus
    DoCmd.FindRecord TilbudId, acEntire, , acSearchAll, , acCurrent

Docmd.TilbudId.SetFocus  <= TilbudId is hear the name of a Text field (How to pass TilbudId: TilbudId as ????(Text field)

DoCmd.FindRecord TilbudId, acEntire...  <=TilbudId is hear the value in TilbudId ( I pass this in normal way as: TilbudId as Long)
Avatar billede per2edb Praktikant
27. januar 2013 - 14:33 #7
It is only:
Docmd.TilbudId.SetFocus 
That is my problem

DoCmd.FindRecord TilbudId, acEntire...  <= No problem. Forget this
Avatar billede per2edb Praktikant
27. januar 2013 - 14:42 #8
Sorry sorry


I want to place this in a sub:

    frmOrdre_PO.SetFocus   
    frmOrdre_PO!TilbudId.SetFocus
    DoCmd.FindRecord TilbudId, acEntire, , acSearchAll, , acCurrent

frmOrdre_PO!TilbudId.SetFocus  <= TilbudId is hear the name of a Text field (How to pass TilbudId: TilbudId as ????(Text field)

DoCmd.FindRecord TilbudId, acEntire...  <=TilbudId is hear the value in TilbudId ( I pass this in normal way as: TilbudId as Long)
Avatar billede terry Ekspert
27. januar 2013 - 15:32 #9
Have you looked at the link about how to use subs/functions? You may learn something form doing so.


I am sure there are many other ways to do what you want but this I think is what you are asking. Again I have not tested.



call SearchRecord("TilbudId", 1234)


Sub SearchRecord(fldName As String, fldValue as Long)


    frmOrdre_PO.SetFocus   
    frmOrdre_PO(fldName).SetFocus
    DoCmd.FindRecord fldValue acEntire, , acSearchAll, , acCurrent



End Sub
Avatar billede per2edb Praktikant
28. januar 2013 - 11:05 #10
Thanks it work

Have you looked at the link about how to use subs/functions? You may learn something form doing so. <= Yes but it is impossible to read watt microsoft explane.
Avatar billede terry Ekspert
28. januar 2013 - 20:43 #11
:o)

No problem, you got it to work, and thanks for the pints.
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