how to get listbox item to reflect the current record

guixian88

New member
Local time
Tomorrow, 05:06
Joined
Jun 8, 2004
Messages
8
hi...

i have a form with a listbox. when i click on a listbox item, the form will display the record connected to that list box item.

however, to add a new record, i click on an Add button which sets the AllowAdditions property to True which brings me to a new record. When i'm done filling in details, i click Done, to turn off AllowAdditions and go to the new record. However, when the new record is displayed, the last item selected is still highlighted, how do i get the listbox to select the new record?
i've been playing around with the listbox properties like .Selected but it keeps giving me errors.

on a side note, i used microsoft's method of disabling the mouse scroll function. after implementing it however, whenever i make changes to the code of the form that i placed the disable mouse code, when i save and reopen the form, Access hangs. so i hv to use task manager to shut it down and reopen a gain. pretty irritating. has anyone else experienced this?
 
On the first issue, You say you have a "Done" button. This button should include the "DoCmd.RunCommand accmdSaveRecord" line

Follow that with Me.ListBoxName = Me.AutoNumber Field

Presuming that the bound column in the Listbox is the autonumber field.

If all else fails put Me.ListBoxName = Null This will clear the lighlight in the listbox.

Dave
 
Hey...thanks....

The code was exactly what i was looking for. And thanks for the extra tip about the Save too.. But I have a question. The command would only be saving the current form, yes? Would it also save records in the subform? i'm thinking no, rite? In that case, what command would i use to save records in a subform?

Erm...any thought on the other issue abt the form that hangs?? :)


Thanks for replying.
 

Users who are viewing this thread

Back
Top Bottom