Results 1 to 9 of 9
  1. #1
    edson is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2014
    Posts
    57

    List column(x) reads null

    Good evening! Hello from Brazil to you all !!!

    OVERVIEW
    I have attached a small db to illustrate my problem.
    TblAtzNor is a price table. I can input prices today to be effective today or at any future date, meaning the ordinary keys will not necessarily match the ascending effective dates. This table is the data source for the FrmBuscaPrNor.
    FrmBuscaPrNor will be triggered thru the FrmCadastro, so if I select Price Type "NORMAL" from the combo in the FrmCadastro then the FrmBuscaPrNor will pop up showing a price list. I want to click in that price list to pick a price based on its Effective Date. The picked price should load my FrmCadastro. However, I want to warn the user when he does not pick the current price.
    Keep in mind that my price list does not show future effective date prices. In addition, current price can be from a month ago (still current). That is the reason why I based my instruction of the Private Sub LstPrNor_Click() event on DMax effective date and not on DLast input date.

    THE PROBLEM


    In the Private Sub LstPrNor_Click() event the system does not get into the first leg of the "If" instruction because it reads null for Me.LstPrNor.Column(6). As a result I get the warning in all cases, in spite of the user choice. I don't have a clue on how to make it work. I do not understand why it reads null in the Me.LstPrNor.Column(6).
    Why is it so tricky? What is wrong, please? Thank you.
    Attached Files Attached Files

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    There are only 6 fields in the listbox row source. The column property is zero based, so Column(6) refers to a non-existent 7th field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    edson is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2014
    Posts
    57
    Hello Paul. Thank you for your prompt reply.
    You are partially right. I forgot to include the 7th column when I prepared the example. But, please note that even adding the 7th column (NORHVIG) in the List source data query (marked as not to show) the problem remains, e.g., the very first leg of the IF does not read and the warning message remains in spite of the price picking. Did you find any sintax / logic error in my code?
    Thanks

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Let's clarify, you want it to show in the row source query, you hide it in the listbox by using the column widths property of the listbox. Is that how you did it?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    And I'm never partially right. I'm always completely right...except when I'm completely wrong.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    edson is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2014
    Posts
    57
    Quote Originally Posted by pbaldy View Post
    And I'm never partially right. I'm always completely right...except when I'm completely wrong.
    That is a good way to put it, eh, eh, eh... I like your sense of humor.
    I am attaching a new version of the db example where I fixed the list quantity of columns.
    Please check the list data source query. It has now the 7th column which is marked to be hidden when you run the query. Also, the list has the 7th column lenth property set as zero to not show in the list.... but it is there for processing purposes. Meaning I do not need to see NORDTVIG in the list but its value should be considered in my instruction.
    So you'll verify that even with the 7th column in place (NORHVIG) the problem remains, e.g., the warning message will pop up in spite of the price you select, which is wrong. I need to warn the user only when he picks an old price. If he picks the current price (the one which matches Max NORDTVIG <= Current Date) no warning message should pop up.
    I believed my code would do that but it does not... that is why I posted this thread. Is it clear enough now? I apologize for my foreign English... It is not native and maybe it is not clear enough.
    Thanks
    Edson
    Attached Files Attached Files

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It's me who's not being clear apparently. You need to check the "Show" box in the row source query for that field. Otherwise it is not available to your code. If you want to hide it in the listbox, set the list width for that column to 0, as you have for others.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    edson is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2014
    Posts
    57
    WOW!!! Amazing! It worked! I am so glad to have learned this basic lesson. I really had in mind that every field of a query would be available for the code even if marked as "not show". I thought it would be kept in the Access "memory"... and you have demonstrated that it is not true. Thank you Paul for being patient with me. I'll mark this thread as solved. Have a blessed day and a nice weekend.
    Edson

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help Edson! Only fields in the SELECT clause are returned by the query, and un-clicking Show removes a field from the SELECT clause.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 9
    Last Post: 06-19-2014, 10:38 AM
  2. Replies: 1
    Last Post: 03-12-2014, 03:13 AM
  3. Replies: 1
    Last Post: 03-25-2012, 05:36 PM
  4. Setting NOT NULL for an column
    By cwwaicw311 in forum Forms
    Replies: 1
    Last Post: 02-21-2010, 10:30 PM
  5. List box value to variable - invalid use of null?
    By Orabidoo in forum Programming
    Replies: 2
    Last Post: 05-07-2009, 11:06 AM

Tags for this Thread

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