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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auto select combo box

Status
Not open for further replies.

cneill

Instructor
Mar 18, 2003
210
GB
current situation is

Form has a combo box by selecting an item in the list the form then moves to that record.

I can add a new item to the list but I would like to do is automatically after adding the new item to the list move the form to the newly added record.
I have requeried the form so the new record is there.
Can any one help me with this?
 
After the requery, setfocus to the field you want to search on (i.e. primary key) and issue the following:

DoCmd.FindRecord "YourSearchString", , , acSearchAll, , acCurrent
 
F9 will refresh the combo box list but set focus and then perform the search

Me.combo.SetFocus
DoCmd.FindRecord GetID(SearchValue)

Where GetID is a custom function that will return the ID for the search value!
 
How are ya cneill . . .

Here's the idea:
[ol][li]Hold the PK (PrimaryKey) of the record in a variable, say ... [purple]hldPK[/purple][/li]
[li]Requery![/li]
[li]Perform the following:
Code:
[blue]   Me.Recordset.FindFirst "[PKname] = " & [purple][b]hldPK[/b][/purple][/blue]
[/li][/ol]
The above assumes the PK is numeric. If PK is text you'll have to make the necessary adjustments.

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

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks everyone, just gave me the direction I needed all fixed now,
Thanks once again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top