Setting the current menu item of a popup button list

I have searched the forum, but still cannot find a solution. Please forgive me if I missed something.

The popup button of my main window draws its data from a table in mySQL, and although the list changes infrequently, I have it load up every time from the table into a 2 item list with the ID number of the item, and the string value with this format:

{{1,"string01"},{2,"string02"},{3,"string03"}}

I then populate the popup button list of menu items using the string value in item 2 of each item in the primary list. When the user chooses an item in the list, it is sent to a handler to extract the ID number (item 1 of the list), which is then written to another table in the mySQL DB. (That whole relational DB thing, you know.)

Anyway, I would like to set the ID number to a property value, so that the next time the application is launched, the popup button will start with the same menu item it left off with the last time. I assumed that I could access menu items as a typical list, in this fashion:

tell menu of popup button "choices" of window "main"
set title of current menu item to menu item (item xx of menu items) -- xx here is the property that holds the ID number, which should also be the item number of the list of menu items
end tell

It does not work, and neither does this:

tell menu of popup button "choices" of window "main"
set title of current menu item to (menu item (item xx of menu items))'s title -- xx here is the property that holds the ID number, which should also be the item number of the list of menu items
end tell

So, really, my question is how to tell the popup button to set the current menu item to something other than the first item in the list, hopefully by using the reference to which list item you want?

Thank you, I hope I have been clear.

These all work for me…

tell popup button "PopUp" of theObject
	set current menu item to menu item 2 --> By index
	-OR-
	set current menu item to menu item "ItemNo3" --> By AS object name
	-OR-
	call method "selectItemWithTitle:" of it with parameter "Item3" --> By title (using obj-c)
end tell

j

… or by title without Objective-C:

set current menu item to (first menu item whose title is "Item3")

Thank you both, I appreciate the quick and effective replies, your solutions function as advertised.

Hope you are keeping up with your AS Studio reference thread, jobu.