Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26
  1. #16
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954

    As previously stated twice I believe you need a semi colon after each item.
    Add a debug.print line to understand why
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  2. #17
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    You still have not answerred the question as to what type of listbox is this?
    is it a value list listbox or a listbox based on a query?
    we are just guessing its a value list but i suspect it isnt.

    try this

    Code:
    Private Sub Addtolist_Click()
    debug.print vol_my_worked_hrs.RowSource
    End Sub
    then copy and paste the result from the immediate window here so we can see what we are dealing with.

    the title to your question
    Changes in listbox dont go into the database. Why?
    are you trying to save the changes to a table?
    what do you mean by "dont go into the database"?

  3. #18
    ijared is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    19
    Quote Originally Posted by ridders52 View Post
    Add a debug.print line for the right side of the equals sign before that line.
    Run the code and look at the result in the immediate window.
    You should be able to see the reason from that.

    If not paste the result into the listbox row source and view in the form
    Hi,
    What do you mean by "Add a debug.print line for the right side of the equals sign before that line.
    Run the code and look at the result in the immediate window."

  4. #19
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    What do you mean by "Add a debug.print line for the right side of the equals sign before that line.
    I was afraid you wouldn't understand this and that's why I made suggestion in post #13 for msgbox.
    Have you tried that?

  5. #20
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Quote Originally Posted by ijared View Post
    Hi,
    What do you mean by "Add a debug.print line for the right side of the equals sign before that line.
    Run the code and look at the result in the immediate window."
    Following on from davegri's comment, I had to search back to my first reply in post #2 for that (written on 2nd April - over 3 weeks ago)

    Your original code from post #1 and repeated in post #17 was as below (with a Debug.Print line added by me)

    Code:
    Private Sub Addtolist_Click()
    vol_my_worked_hrs.RowSource = vol_my_worked_hrs.RowSource & MyText1 & MyText2 & ";"
    Debug.Print  vol_my_worked_hrs.RowSource & MyText1 & MyText2 & ";"
    End Sub
    Adding a Debug.Print line sends the output to the Immediate window which is found in the VB Editor.
    This is very useful for developers to find out what is happening in parts of their code.
    As Davegri mentioned, a message box is a convenient alternative
    MsgBox "vol_my_worked_hrs.RowSource & MyText1 & MyText2 & ";""

    Run the code with the Debug.Print line, then copy the information shown in the Immediate window in your next reply
    Alternatively replace the Debug line with a message box & do a screengrab of what is shown

    As mentioned several times, I believe you need a semicolon after strText1 (though I may be wrong)
    Code:
    vol_my_worked_hrs.RowSource = vol_my_worked_hrs.RowSource & ";" & MyText1 & ";" & MyText2
    Only by seeing your output (as described above) or by you testing that idea can this thread make much progress
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #21
    ijared is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    19
    Finally this worked
    Me.My_Worked_hrs.AddItem Me.MyText1
    Me.My_Worked_hrs.AddItem Me.MyText2

    This is a second list My_Worked_hrs box. The first one vol_my_worked_hrs was a combo box converted to a list box.
    I have to send this to the database. How do do I do that? Have looked around but havent found a better one yet.
    Thanks anyway.

  7. #22
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    @ijared,
    I have beel following your thread. You have been helped by two very knowledgable people, ridders52 & davegri, each with over 1000 posts; moke123 also seems knowledgable.

    To receove good, applicable responses, you need to answer questions asked of you. But you seem very good at not answering when question asked of you.

    moke123 asked questions in Post # 15 which you ignored; questions were asked again in Post #17 - again ignored.
    (pretty much the same questions I have)

    So the title of your thread is:
    Changes in listbox doen't go into the database. Why?

    You started talking about HOW you are trying to do something, but never explaining WHAT you are doing...... two very different things.

    What I can gather is:

    * You have a list box
    * The Row Source of the list box is a value list.
    * You expect additions to the list box value list to be saved - not sure where yet.



    Quote Originally Posted by ijared View Post
    Finally this worked
    Me.My_Worked_hrs.AddItem Me.MyText1
    Me.My_Worked_hrs.AddItem Me.MyText2
    Just curious....Do you have code to check that MyText1 and/or MyText2 are NOT NULL and/or NOT an Empty String??



    So explain what you mean "doen't go into the database"???

    From post #21
    Quote Originally Posted by ijared View Post
    I have to send this to the database.
    What is this??
    "Sent this to the database" - do you mean save the value list to a table?


    If you expect the additions to the list box to be saved somewhere, then you are using the wrong method.
    There should/would be a table to store the data for the list box. Code would be used to append (add) the new data (MyText1 & MyText2) to a table.
    A query (based on the table) would be the Row Source of the list box. Then the data additions would be "saved to the database".




    -------------------------------------------------------------------------------------------------------------
    My post is NOT to burn/chastise you but to try and explain why it is taking so long (21 posts and counting) to try and resolve your questions.
    The better you are at explaining and providing info, the easier it is to provide a (hopefully) valid solution.

  8. #23
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    Finally this worked
    Me.My_Worked_hrs.AddItem Me.MyText1
    Me.My_Worked_hrs.AddItem Me.MyText2
    I suggested that in post#9 however you said it didnt work.
    Ling indicated in post# 10 that this data would not be saved with this method.

    Bear in mind that we cannot see what you are working with, which is why we ask questions.

    now lets try to resolve your issue with saving the data to a table.
    Describe as best you can what the relevant tables look like and what type of form your working with.
    Even better is to post a stripped down sample of you database with just the relevant tables and forms.

  9. #24
    ijared is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    19
    I'got it working. I convert a combobox to a listbox and that must be a reason why nothing was going in. Now I have to figure out how to save this data evrtime data is put in..

  10. #25
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    I convert a combobox to a listbox and that must be a reason why nothing was going in
    Probably not as both use the exact same syntax

    there is no need to have 2 posts for this question especially if you ignore questions. (for some reason chrome wont let me link to your question "listbox doesn't populate")

    if your intent is to save this data to your database you are going in the wrong direction.
    you should be saving data to a table and if you want to DISPLAY the data in a list box you would use the table/query as the data source of your list box.

  11. #26
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643

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

Similar Threads

  1. Replies: 6
    Last Post: 01-02-2018, 10:56 AM
  2. Replies: 1
    Last Post: 09-11-2012, 11:49 PM
  3. Replies: 1
    Last Post: 09-10-2012, 11:21 PM
  4. projects database save listbox selections
    By taya621 in forum Access
    Replies: 33
    Last Post: 01-21-2011, 10:56 AM
  5. Replies: 1
    Last Post: 10-20-2009, 02:05 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