Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List listindex problem 1

Status
Not open for further replies.

ZOR

Technical User
Jan 30, 2002
2,963
GB
New Records are being entered into a table in which the list source query sorts records by the content of a time field (not current) in each record. After they have entered a record, the list gets requeried to add the new record in, and sorts it. Next, I want the list clicked on the record they have just done so they can edit it. However my problem is knowing the listindex value to get clicked on IF THEY ENTER RECORDS NOT IN THE ORDER OF THE TIME FIELD. I did have it set so it clicked on Listindex 0, thinking this would always be the case, but now it will not always work, and they get the wrong record to edit straight after save. Any suggestions? Thanks
 
Hi ZOR,

Seems to me, you want to know the last record added. If this is the case, then you should be storing both the date AND time field (but only displaying the time portion for the user).

In any case, how is the time portion alone useful to the user - should it not be date and time already?

This way, you can ascertain the last record added.

ATB

Darrylle




Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
Howdy ZOR . . .

Don't quite understand editing the same record twice but you don't need to click the listbox if you hold the PK of the currently saved record:
Code:
[blue]   hldPK = Me!PKname
   [green]'Requery List[/green]
   Me.Recordset.FindFirst "[PKname] = " & Me!PKname[/blue]
If you still need the listindex or have the selection made you'll have to loop thru a column looking to match data (because of sorting you know not where the index will reside). Something like:
Code:
[blue]Private Sub SelIdx(Dat)
   Dim LBx As ListBox, x As Long
   
   Set LBx = Me![purple][b][i]ListboxName[/i][/b][/purple]
   
   For x = 0 To LBx.ListCount - 1
      If LBx.Column(1, x) = Dat Then
         LBx.Selected(x) = True
         Exit For
      End If
   Next
   
End Sub[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Many thanks, the timefield at entering a record is a good one, might now also consider putting the name of the person in as well for later use. In the meantime I started sorting my list out in Primary key number, and its down to them to put in records sequectially. The time fields are video start/stop times of events on tape, hope that fixes the mystery. Have a star for useful help. Best regards
 
Hi Ace,

Referring to your "Your Thoughts?..."...

I understood ZOR's problem to be simply: "How to identify the most recent record added to a child-table..."

Zor has a combo that is populated from the child-table. This child-table has a new record added by the user, and then the combo is to be shown with the most recently added record displayed within it.

Within the child-table - how do you determine the last record added with only the time portion saved within it? You can't - you need the date also.

I will however bet that you have spotted a future problem Ace - no? [wink]

ATB

Darrylle

Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
My problem is the records are shown on a listbox. The records contain Time Start and Time end fields with other data. Ideally, the list should always show decending view down the time fields in the columns. The Time fields are not related to current time, they are at the time of videoclips being recorded. When a user enters a record it was easy if the record landed always at the top of the list to call a list click which presented ther data of the record for any further editing. However if they put a record in that had midway time fields, the record would be presented half way down the list, so my list click of zero listindex got the wrong record back to edit. At the moment I have made the list in ascending record ID, which puts it at the top of the list, but the viewing of the list columns of time are all over the place, hope thats not confused everyone. Thanks
 
How are ya ZOR . . .

Thanks for confirming I did interpret your post origination correctly.

Is there a [blue]PK field[/blue] involved in the listbox?

If not . . . [blue]can you make it so?[/blue]

[blue]A decending sort on the PK should always put the latest record at index 0![/blue] [thumbsup2] . . . no matter what start/end time.

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Hello, thanks for comming back. Yes there is a primary and a foreign key in the listbox. The listbox is on a subform. As I said, I am now sorting the list for view in the foreign key order. This works well if the user puts in records in sequential order to whats in the Time field, so the list is logical to look at. As soon as the record has been entered and the listbox requeried, the list gets a click call so the user can see what he's just added, and make sure its all correct and nothing extra to put in. Its a shame that when to record gets entered that I cannot know what the listindex is likely to be so even if its been put in the middle of the list I can go to it. Hope it makes sense, thanks again. Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top