Results 1 to 4 of 4
  1. #1
    Join Date
    May 2009
    Posts
    4

    Unanswered: Use Listindex -1

    HI ALL
    I HAVE TWO COMBO BOX BOUND TO PRIMARY FIELD ON ONE TABLE AND THOSE COMBO BOXS IN ONE FORM.
    AND I NEED TO PREVENT DUPLICATE VALUE BETWEEN THEM
    SO I THOUGHT THAT I HAVE TO SET ONE OF THIS COMBO TO BE LISTINDEX -1


    THIS PHOTO OF WHAT IN NEED

    http://www.arb-up.com/files/arb-up-2008-6/kcH52997.gif

    AND I ALLRADY UPLOADED MY PROGRAM IN THA ATTACHMENTS
    Attached Files Attached Files

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    From looking at your gif pic (I haven't had the chance yet to look at the mdb), it looks like you just need to add code in the OnClick event of the Edit button. Perhaps something like this (taken from memory so excuse any syntax errors):

    Button on click event....

    me!Requisition2FieldName = me!Requisition1FieldName (ie. the field under the Requisition Number button)
    ....your other code to do the editing...

    If the values of the 2 comboboxes are different (ie. 1 is the primary key value while the other combobox is a different field number), then make it so you can grab the correct value from Requisition1FieldName to correspond what the value should be in Requisition2FieldName.

    For example, edit the rowsource for Requisition1FieldName and add the column which would match the corresponding value in the table in the Requisition2FieldName.

    Then make sure you add 1 to the column count and add ;0" for column width's to the combobox. If it's the 2nd column in the query, you're code (in the Edit button OnClick event) would then look like this:

    me!Requisition2FieldName = me!Requisition1FieldName.Column(1)

    (note: I'd actually put something like this for null checking...)

    if not isnull(me!Requisition1FieldName) then
    me!Requisition2FieldName = me!Requisition1FieldName.Column(1)
    ....your other code to do the editing...
    else
    msgbox "You must first enter the Requisition number!"
    me.Requisition1Fieldname.setfocus
    end if

    or if it's the 3rd column...

    me!Requisition2FieldName = me!Requisition1FieldName.Column(2)

    (note: it's always 1 less for referencing columns in a combobox.)

    (also note: you can do the opposite by editing the rowsource, column's for the Requisition2FieldName. Either way, from looking at your diagram, it just looks like you need to get the two comboboxes to relate to the same field value in the table - ie. editing one or both of the rowsources, column's so that the value from Requisition1FieldName can be copied into Requisition2FieldName and your code can then fire for the correct value in Requisition2FieldName.)

    (and again note: You can also do something similar with the combobox field under the Project button to set the value in Requisition1FieldName.)

    I guess I'm not sure why you need to use the ListIndex property.
    Last edited by pkstormy; 05-27-09 at 21:31.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    May 2009
    Posts
    4
    First Thanks
    Second.
    The Requisition (1) Is Unbound Combo Box And It's Just For Filtering The Number Of The Requisition In The Each Project.
    And All What I Need Just A Code Like Listindex -1 To Deselect In The Combo Box Requisition ( 2 )

  4. #4
    Join Date
    May 2009
    Posts
    4
    Hey Guys

    Isn't There Any Solution

Posting Permissions

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