Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    As already mentioned BrowseTo invalidates the object referenced by Me, because the form is closed after executing the BrowseTo. As the code runs to it's end, you can store the value of Me.TextBox in a local variable, do the BrowseTo and apply the value from the local variable to the text box of the new form that was just opened by BrowseTo. You can add a Public Property to your form as well and use the put sub to react on a change of the value from outside of the form.

  2. #17
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by hapm View Post
    ...As the code runs to it's end, you can store the value of Me.TextBox in a local variable, do the BrowseTo and apply the value from the local variable to the text box of the new form that was just opened by BrowseTo....
    I do not understand this as being possible.

  3. #18
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    ItsMe is correct about global variables losing their value during a run-time error. That's where TempVars are supposed to have an advantage.
    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.

  4. #19
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    Quote Originally Posted by ItsMe View Post
    I do not understand this as being possible.
    Dim tmp
    tmp = me.TextBox
    DoCmd.BrowseTo ...
    Forms![New Contact].[IDFieldName].Value = tmp

    Well, you will need to fix the reference to the control as it is in a subform.

  5. #20
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    hapm, I think the issue with local variable and Navigation form is the form with the local variable is closed by BrowseTo before the variable can be used to populate the second form, hence the need for global variable.
    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.

  6. #21
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    The funny thing here is that the code runs to its end, even so the form is already cleaned up. The only thing you can't do is using Me after the BrowseTo, as the referenced object behind this variable is marked as closed (even so it still exists until the code has finished of and all dereferenced objects get cleaned from memory.

  7. #22
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Ooops, yes, of course, the first form code is pushing value to the second form. I do that with normal forms (guess I had wires crossed with referencing the control after form is closed which would fail but setting variable retains the value until code finishes). Don't see why navigation form should be different.
    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.

  8. #23
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    That's pretty cool. I have never tried anything like that before.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. How do I update a Table from a Pass-Through Query
    By smc678 in forum Programming
    Replies: 6
    Last Post: 06-27-2013, 08:18 AM
  2. Update access table from a pass-through query
    By francesco in forum Access
    Replies: 3
    Last Post: 07-02-2012, 05:49 AM
  3. Replies: 3
    Last Post: 06-29-2012, 01:31 AM
  4. Insert Pass-Through Results into Access Table with VB
    By raynman1972 in forum Programming
    Replies: 3
    Last Post: 06-20-2012, 08:43 PM
  5. Pass Variable to Table Field with VBA
    By dgj32784 in forum Programming
    Replies: 3
    Last Post: 03-28-2011, 09:36 PM

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