Results 1 to 10 of 10
  1. #1
    cesarone82 is offline Novice
    Windows 11 Access 2016
    Join Date
    Jun 2009
    Posts
    25

    Empty value in VBA despite value in record is set

    HI, I'm getting a strange behaviour in VBA for the "civi" value, I have various variables set, for example "Località", I can get the value of all of them, but for some reason the civi variable in vba is listed as empty despite it has a value assigned, On the button with the "A" in the project forms I just put some line of code to assign a test variable with civi and Località, by debugging I can see that Località works but civi seems empty.
    I cannot understand the reason behind this beahaviour.
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Too late a version for me.
    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
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I suggest you provide more info re the issue and how to repeat it. More specific directions. It also helps with context if you show/describe
    A)what you have currently, and also show
    B)what you want.

    For consideration:

    -Always have Option Explicit as second line in every module
    -Give meaningful names to your controls
    -design some test data
    -make use of strategic Debug.Print to check program/logic flow

    You may have division by 0 in this expression
    Code:
     =([pj$]-[tbl_pjentries].[Form]![Text20])/[tbl_pjentries].[Form]![Text11]

    I do not see where civi is collected?

  4. #4
    cesarone82 is offline Novice
    Windows 11 Access 2016
    Join Date
    Jun 2009
    Posts
    25
    Hi thanks for the reply,

    I have to cut part of the code cause of the reference to the phantom pdf library, what i need is to fill some PDF fields with values from my record. Inside my access file, in the frm_projects (record pjnum 32) I have a button doing this (the button with the A) where i just put in the dblclick an assigment to two test variables, first one is test1=Località which correctly set the localita field to test1 variable.
    The second (test2) is testing the field civ, which inside record 32 is value 41A (see tbl_projects pjnum 32) but test2 variable upon assignement is empty string. I cannot figure out why considering that I can successful retrieve località field and all others, but not the civ fiels.

    See below test2=civ inside VBA should be 42A when launched from form_projects record with pjnum 32Click image for larger version. 

Name:	Screenshot 2023-12-01 145822.jpg 
Views:	16 
Size:	83.4 KB 
ID:	51131

  5. #5
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Quote Originally Posted by cesarone82 View Post
    first one is test1=Località which correctly set the localita field to test1 variable.
    No it doesn't.
    It sets Test1 to the value of Località

    Unless that is a language issue - I appreciate English is probably not your first language?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    you may be bringing civi through in your recordsource, but you don't have it on the form.

    try me!civi

    which includes referencing the recordset

  7. #7
    cesarone82 is offline Novice
    Windows 11 Access 2016
    Join Date
    Jun 2009
    Posts
    25
    Sorry I'm Italian but i wrote too quickly . In fact the issue is not with test1 variable which is correctly assigned with the value of localita field.

    The issue is with test2 which should be "42A" but is "", Yes I know that there is no civi field in the form, but to me it seems that it is not required to have it in the form, since even if localita is not present in the form it correctly assign test2 with its value.

    I also had the same idea, but even if I add civi control in the form the content of test2 is "". Apart this error do you confirm that I don't need a form control with a certain value in the form to retreive the value if this one is present in the table on which the form is based? If not how is possible that i can get the value of localita in vba dblclik event in the project form?

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    if i type in the sub

    me.c

    civi does not appear in the dropdown


    and if I type

    me.lo
    Località appears in the dropdwon


    So somewhere you have associated the field Località to the form - perhaps in a control you subsequently deleted

    If I add civi as a control, I see a value
    Click image for larger version. 

Name:	image_2023-12-01_165317228.png 
Views:	13 
Size:	2.5 KB 
ID:	51135

    and if I subsequently delete the control - the value remains

    SO either add the control, then delete it, or use Me!

  9. #9
    cesarone82 is offline Novice
    Windows 11 Access 2016
    Join Date
    Jun 2009
    Posts
    25
    Thank you, I was a bit confused about the fact that Località was working, I don t remember adding it. Anyway the fact that adding and deleting it makes the thing work is a bit confusing.

    Quote Originally Posted by CJ_London View Post
    if i type in the sub

    me.c

    civi does not appear in the dropdown


    and if I type

    me.lo
    Località appears in the dropdwon


    So somewhere you have associated the field Località to the form - perhaps in a control you subsequently deleted

    If I add civi as a control, I see a value
    Click image for larger version. 

Name:	image_2023-12-01_165317228.png 
Views:	13 
Size:	2.5 KB 
ID:	51135

    and if I subsequently delete the control - the value remains

    SO either add the control, then delete it, or use Me!

  10. #10
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    Also note that you need to have option explicit declared in ALL your modules.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

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

Similar Threads

  1. check for field in record not empty
    By jtan in forum Forms
    Replies: 6
    Last Post: 09-19-2020, 06:46 AM
  2. UPDATE blank or empty record row
    By aaendewy in forum Access
    Replies: 5
    Last Post: 06-19-2018, 08:06 PM
  3. Replies: 1
    Last Post: 02-28-2018, 01:02 PM
  4. Replies: 5
    Last Post: 04-16-2014, 08:25 AM
  5. Go to first empty record
    By westcoastbmx in forum Forms
    Replies: 2
    Last Post: 10-30-2009, 01:37 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