Results 1 to 5 of 5
  1. #1
    joshynaresh is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2013
    Posts
    131

    Getting value from other form

    Hi Buddy !


    Suppose I have 4 form name : frm1,frm2,frm3 and Frm4. frm1,frm2 and frm3 have 1 commandButton and 1 field. field contain their form name i.e. frm1's field value is "Frm1", frm2's field value is "frm2" and frm3 's field value is "frm3". and commandButton contain code:
    Code:
    docmd.OpenForm "frm4",acNormal,,,,acDialog
    frm4 has i textbox.
    My requirment is:
    if frm4 open by frm1's commandButton then frm4's textbox value should be "frm1"(frm1's field value)
    if frm4 open by frm2's commandButton then frm4's textbox value should be "frm2"(frm2's field value)
    if frm4 open by frm3's commandButton then frm4's textbox value should be "frm3"(frm3's field value)

    Can we can do this?
    if yes then plz provide me code.
    there is no any hidden purpose of asking this question. i just want to know can we? if yes then how?\
    Thanks in advance.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    One way is to use OpenArgs argument of DoCmd.OpenForm

    frm4 opened by frm1:

    DoCmd.OpenForm "frm4", acNormal, , , , acDialog, "frm1"

    Then textbox on frm4 has expression in ControlSource: =[OpenArgs]
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    joshynaresh is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2013
    Posts
    131
    if frm4 have 3 textbox and these textbox value will be from different textbox of frm1 if frm4 open by frm1 commandbutton
    if frm4 have 3 textbox and these textbox value will be from different textbox of frm2 if frm4 open by frm2 commandbutton
    if frm4 have 3 textbox and these textbox value will be from different textbox of frm3 if frm4 open by frm3 commandbutton

    how can we get value.

    Thanks in advance

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Name the 3 textboxes on each form with same names. Use the value of OpenArgs to dynamically refer to form.

    Code in frm4 OpenEvent.

    Me.textbox1 = Forms(Me.OpenArgs).Controls("textbox1")
    Me.textbox2 = Forms(Me.OpenArgs).Controls("textbox2")
    Me.textbox3 = Forms(Me.OpenArgs).Controls("textbox3")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    joshynaresh is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2013
    Posts
    131
    Thanks. Problem solved

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums