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

Update List Box

Status
Not open for further replies.

CGSB

Programmer
May 23, 2006
35
CA
I have a bound list box. It lists a value called "file_no".

When a new record is saved, I want it to requery, and automatically select the new "file_no".

Any ideas?

 
If I understand what you are asking.

Private Sub Form_AfterUpdate()
Me.lstFile_no.Requery
End Sub
 
No that's not it. I got it to requery already.

I guess what I'm asking for... if it makes any sense... is how can I copy the list box's recordset so that I may set the selected value (or bookmark) to the new file_no. Something like the following, but that actually works.

Dim rsListBox as Object

Set rsListBox as Me!ListBoxName.Recordset

rsListBox.Movelast

ListBoxName.Bookmark = rsListBox.Bookmark
 
If I understand, you want the value of the new record equal the value of the last record selected. Maybe something like this.

Code:
Private listVal As Variant

Private Sub Form_Current()
  If Me.NewRecord And Not Trim(listVal & " ") = "" Then
    List11.Value = listVal
  End If
End Sub

Private Sub Form_Open(Cancel As Integer)
  listVal = list11.value
End Sub

Private Sub List11_BeforeUpdate(Cancel As Integer)
  listVal = List11.Value
End Sub

Or using the default value

[/code]
Private Sub Form_Current()
If Me.NewRecord Then
List11.Value = List11.DefaultValue
End If
End Sub
Private Sub List11_BeforeUpdate(Cancel As Integer)
Me.List11.DefaultValue = Me.List11.Value
End Sub
[/code]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top