how to make listbox automatically scroll to bottom

R

RCGUA

I have a form with a listbox named "lstEmployeePayments". The code
below is triggered by an afterupdate event from a combobox.
Basically, you pick a name from the combobox and then the listbox
displays data for that name, but when the list is longer than the box,
the most recent data does not show because the box is scrolled to the
top. I the listbox to scroll to the bottom.
The code below scrolls to the bottom of the listbox, but, the problem
is that after it does that, then I cannot save a record. I can't do
anything with the form because I get an error messsage Run-time error
2115 "the macro or function set to the BeforeUpdate or ValidationRule
property for this field is preventing MyDatabase from saving the data
in the field."

Me.lstEmployeePayments.Selected(lstEmployeePayments.ListCount - 1) =
True
 
P

Piet Linden

What code do you have in the BeforeUpdate event of the form? Does
the field in the table have a validation rule? Is there one for the
control on the form? I recreated a scenario similar to yours, and I
can save the selection chosen in the listbox. (No multi-select is
allowed, though, because that returns a collection of values and not
an individual value.)
 
R

RCGUA

What  code do you have in the BeforeUpdate event of the form?  Does
the field in the table have a validation rule?  Is there one for the
control on the form?  I recreated a scenario similar to yours, and I
can save the selection chosen in the listbox.  (No multi-select is
allowed, though, because that returns a collection of values and not
an individual value.)

Thanks for your help, I really appreciate it.
I don't see any events or rules like you described, however, I will
keep looking and try to eliminate anything that might be causing the
problem. I will also try to create a new scenario the way you did,
that's a good idea.

I made a few changes and I get this error message: "Update or
CancelUpdate without AddNew or Edit"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top