By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,326 Members | 2,726 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,326 IT Pros & Developers. It's quick & easy.

Select newly added element in a list based on a sql

P: n/a
I am using WinXP and MS Access 2003.

I have a list whose row source is an sql. I insert a new record to the
table the sql takes its data from. I requery the list and the new
record appears.

Problem: As soon as I have done the requery I want the newly added
element be highlighted in the list. How do I do that?

Regards,

Jan Nordgreen

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
The safest way is to store the value for the record (bound field) and
then simply make the list = to the variable.

You could also use the DLast function and set the list = to it. This
finds the last record in the table.

Nov 13 '05 #2

P: n/a
I tried

Me.lstconstructiontype.Value = Me.txtedit.Value

but that does not select the value Me.txtedit.value in the list
lstconstructiontype.

I also tried

Me.lstconstructiontype.Value = DLast("constructiontype",
"constructiontype")

but to no avail.

I believe Me.lstconstructiontype.Selected(x) = True is the way to
select an element in a list, but I donęt know how to find x in this
case.

Nov 13 '05 #3

P: n/a
I came up with this solution. It is not elegant, but it works:

For i = 1 To Me.lstconstructiontype.ListCount
Me.lstconstructiontype.Selected(i - 1) = True
If Me.lstconstructiontype.Column(1) = Me.txtedit Then
Exit For
End If
Next

I select the elements in the list and check their column(1) value. When
it equals the newly inserted value, I exit the loop.

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.