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
Annonceindlæg fra HP
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
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
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
27. januar 2013 - 14:24
#5
DoCmd.FindRecord Me(NameOfField), acEntire, , acSearchAll, , acCurrent
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)
27. januar 2013 - 14:33
#7
It is only: Docmd.TilbudId.SetFocus That is my problem DoCmd.FindRecord TilbudId, acEntire... <= No problem. Forget this
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)
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
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.
28. januar 2013 - 20:43
#11
:o) No problem, you got it to work, and thanks for the pints.
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser