Results 1 to 13 of 13
  1. #1
    Join Date
    Mar 2004
    Posts
    77

    Unhappy Unanswered: setting the ListIndex property

    hi ppl,

    can the ListIndex property for List Box Control be set using VB code? if yes how? thx in advance.

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    You can read it only, but you can not change its value i.e Read Only property

  3. #3
    Join Date
    Mar 2004
    Posts
    77
    then is there anyway that i can change the list index to 0 or -1?

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    What do you intend to do?

  5. #5
    Join Date
    Mar 2004
    Posts
    77
    i intend to make a form with list boxes for user to choose their choice of events and which tool will get involved. the form will be getting its record source from a table. problem now is that Access won't let me create a new records or close the form without first making the list box's ListIndex to 0 or -1. any ideas how to make the ListIndex to 0 or -1?

  6. #6
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by chanjw
    i intend to make a form with list boxes for user to choose their choice of events and which tool will get involved. the form will be getting its record source from a table. problem now is that Access won't let me create a new records or close the form without first making the list box's ListIndex to 0 or -1. any ideas how to make the ListIndex to 0 or -1?
    Yes ... Set .Value=""

    MyListbox.Value=""
    Back to Access ... ADO is not the way to go for speed ...

  7. #7
    Join Date
    Mar 2004
    Posts
    77
    thanks M Owen, for the method.

    But right now, this is buffling, even if i cleared everything to null or 0, i still cannot get the form to go to a new record. anyone noes why? the error msg is: "You cannot add or change a record because a related record is required in tblEvents."

  8. #8
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by chanjw
    thanks M Owen, for the method.

    But right now, this is buffling, even if i cleared everything to null or 0, i still cannot get the form to go to a new record. anyone noes why? the error msg is: "You cannot add or change a record because a related record is required in tblEvents."
    You have a relationship dependency in the underlying table ...
    Back to Access ... ADO is not the way to go for speed ...

  9. #9
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    If I am reading everything right, that is happening because your parent form hasnt created the primary key needed for the subform to have something to relate to. Try filling out the complete parent form, before filling out the subform.

    I had a similar situation... I had a default date and a default username entered into any new records. This didnt create a primary key, so what I had to do was use the forms OnLoad() function to populate those fields so that it would create the primary key for me. (I use autonumbers for my primary keys. It is just easier for what I am doing).

    I hope this helps,
    If you have any questions let me know,
    Jarvis

    Quote Originally Posted by chanjw
    thanks M Owen, for the method.

    But right now, this is buffling, even if i cleared everything to null or 0, i still cannot get the form to go to a new record. anyone noes why? the error msg is: "You cannot add or change a record because a related record is required in tblEvents."
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  10. #10
    Join Date
    Mar 2004
    Posts
    77
    well, as JSThePatriot said, i do have a parent table. but in this case, i wanted the form to go to a new record AFTER i had filled in one record. I have attached a sample Access DB. How 'bout you guys try it out and suggest what i need to do? :P

    Note: the "Add Record" button is supposed to save the record and go to a new record. And that is when the error msg will pop out. Remember to add in one record first!
    Attached Files Attached Files

  11. #11
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557

    Not quite sure.

    I am not exactly sure I know what the problem is, but I will give it a shot. When you add the record to the database they need to have an Event selected. I tried selecting an event and a tool together but it said I couldnt do that. I tried selecting a tool without an event and it said I have to have an event.

    So you may want to make them select an event. Then a tool. I know you have the box up there but it doesnt seem to be using it to select.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  12. #12
    Join Date
    Mar 2004
    Posts
    77

    Talking Solved!

    hey ppl,

    thx for all the help, but i got it working. i just need to get rid of 2 lines of code and i can get it to go to new record.

  13. #13
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Not a problem. Glad you got it working.


    JS

    P.S. What two lines of code was it if you dont mind my asking.
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •