Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    gprzytula is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2022
    Posts
    16

    transport value of field to another form

    I have a form Beweging_Uit with an input text field : Boek_ref
    I have a save button that executes some code and checks a special condition
    if condition is met I want to open a form Bewegingen_open (that can already be open)
    I added a
    DoCmd.OpenForm "Bewegingen_open", WindowMode:=acDialog
    the form will open if not open or focus is given to that form
    so far so good

    on Bewegingen_open I have also an input text field : Boefref_open

    what I wanted was to fill this Bewegingen_open.Boekref_open with the value of Beweging_Uit.Boek_ref when opened/called

    I added to the code
    ref = [Forms]![Beweging_Uit]![Boek_ref]
    DoCmd.OpenForm "Bewegingen_open", WindowMode:=acDialog, OpenArgs:=[ref] ---> no error

    in the called form Beweging_open :
    I see on open and on load

    does Load mean : when first loaded ?
    and open : opened/called

    I wanted to add
    If Not Nz(Me.OpenArgs, "") = "" Then
    [Forms]![Bewegingen_open]![Boekref_open] = Me.OpenArgs


    End If

    does it mean I have to code this in both on open/on load for new open or already open ?

    It does not return error : but the Beweging_open.Boekref_open is not filled in either case

    Do I understand this wrong or do I do something wrong or incomplete

    Thanks for all help/hints
    Best Regards, Guy

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    When you are in the form, you can just use Me. as I am getting a headspin just trying to identify the forms not in my language'. You have just used Me for the OpenArgs, so you can use Me.Boekref_open or is it Boefref_open ?

    You set OpenARgs in one place and use in a Form or Report when it opens/Loads

    I hope you have Option Explicit at the top of each module?

    Walk through your code with a breakpoint and F8 to move line by line. Then you can inspect the contents of variable.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Maybe this will help
    https://support.microsoft.com/en-us/...7-ce86553682f9

    A form Opens 1st, then it loads records, so don't try to access records in the open event. Since you seem to be dealing with OpenArgs I'll say that you can pass a value to the OpenArgs property of a form, but you cannot edit that property value of an open form - it is read only. AFAIK it's more reliable to edit data/controls in the Load event.

    You should copy/paste code if you have it, rather than free type as there seems to be a difference in spelling here:
    [Boekref_open] VS Boefref_open
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    gprzytula is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2022
    Posts
    16
    thanks for the updates
    yes, it is a typo : Boekref_open it should say : checked in code and form (but was correct)
    Yes I have : Option Compare Database Option Explicit in modules
    the module is not returning error : can debug be activated to walk through the code ?
    this is the code I have in caller form :
    ' --------------------------------------------------------------
    ' check if boek in still open - open form beweging open
    ' -----------------------------------------------------------
    chsql = "SELECT BEWEGING.[IN] FROM BEWEGING WHERE BEWEGING.[IN] Is Null And BEWEGING.RegistratieNr ='" & [Forms]![Beweging_Uit]![Boek_ref] & "'"
    Set rst = CurrentDb.OpenRecordset(chsql)
    If rst.RecordCount > 0 Then
    ref = [Forms]![Beweging_Uit]![Boek_ref]
    DoCmd.OpenForm "Bewegingen_open", WindowMode:=acDialog, OpenArgs:=ref

    End If
    and this in called form

    Private Sub Form_Load()
    If Not Nz(OpenArgs, "") = "" Then
    [Forms]![Bewegingen_open]![Boekref_open] = OpenArgs
    End If
    End Sub

    how to see if something is being transferred - or how to debug
    Thanks for all update
    Best Regards, Guy

  5. #5
    gprzytula is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2022
    Posts
    16
    i activated the debugger and on caller form i can see the value of the variable passed with OpenArgs

    but when I display OpenArgs() in called form, it is null
    best regards, Guy

  6. #6
    gprzytula is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2022
    Posts
    16
    Click image for larger version. 

Name:	2022-05-24_12h21_08.png 
Views:	11 
Size:	4.8 KB 
ID:	47891

    this is the debug output from caller
    and from called
    Click image for larger version. 

Name:	2022-05-24_12h30_49.png 
Views:	12 
Size:	5.4 KB 
ID:	47892

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Do not know what to say. I have never used keyword parameters, always positional, mainly as I do not remember the names.
    I would try hardcoding the 1111
    I would try a test form and open from the command window with ref and hardcoded.
    I would then try Positional parameter, anything really to pin it down somewhere.

    You are taking the correct steps though.

    I have never experienced corruption (hope I have not jinxed myself), but know others have from various forum posts.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #8
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Remove the (). Open args is not a procedure (sub or function).
    Last edited by Micron; 05-24-2022 at 07:06 AM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Quote Originally Posted by Micron View Post
    Remove the (). Open args is not a procedure (sub or function).
    I tried with () in one of my report modules and it still showed the passed parameter?
    I must admit, I never use the () normally.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  10. #10
    gprzytula is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2022
    Posts
    16
    thanks. I also tried with and without () same result : OpenArgs is always null
    I will try openform with positional arguments and not keywords..
    and also with hardcoded value instead of variable
    best regards, Guy

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Upload a cut down version of your DB, just enough to see the problem.
    Unlikely I will be able to look at it as I only have 2007, but others might wish to.

    This is going to be something silly, you watch.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  12. #12
    gprzytula is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2022
    Posts
    16
    i tried with positional and prompting but this does not work as it returns an errorClick image for larger version. 

Name:	2022-05-24_15h50_43.png 
Views:	11 
Size:	39.4 KB 
ID:	47893
    i tried with hardcoded value and in called form OpenArg is always null

  13. #13
    gprzytula is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2022
    Posts
    16
    i tried with positional and prompting but this does not work as it returns an errorClick image for larger version. 

Name:	2022-05-24_15h50_43.png 
Views:	11 
Size:	39.4 KB 
ID:	47893
    i tried with hardcoded value and in called form OpenArg is always null
    also removed () from caller
    DoCmd.OpenForm "Bewegingen_open", , , , , acDialog, "11111"
    also null

  14. #14
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Try using the red line (not the one above it) but remove the (). I might sound like a stuck needle in a record there, but my money is on that being the problem.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  15. #15
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Why are you using brackets all the time?
    I have never used them for open form, not have I see them being offered?

    https://docs.microsoft.com/en-us/off...docmd.openform

    You do not need to run the code all the time. You can test in the immediate window, so much easier.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Replies: 11
    Last Post: 03-09-2018, 10:18 AM
  2. Replies: 6
    Last Post: 07-28-2017, 01:36 AM
  3. Replies: 24
    Last Post: 03-27-2017, 09:24 AM
  4. Replies: 2
    Last Post: 05-29-2013, 01:44 PM
  5. Replies: 2
    Last Post: 03-10-2013, 01:03 AM

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