adding new rec on bound form causes unbound listbox woes

B

Beth F.

Hi all,
Using Access 2000. This is the first time I've worked with bound
forms, so kindly excuse my naivete/improper terminology if possible.

I have a form that is bound to a table. Also on the form are several
unbound listboxes that will force the user into choosing a valid value
when they update a record or add a new one. All of the text boxes and
listboxes are disabled until the user clicks the New Record or Update
Record buttons (the user is allowed to scroll through existing records,
but cannot get into any fields unless they click New or Update).
When the user opens the form and clicks on the "New Record" button
(which does DoCmd.GoToRecord , , acNewRec), they get a new record with
enabled fields, and they can either save the record (provided it passes
some checks), or click the cancel button, which does a me.undo. This
works fine if this is the very first thing the user does upon opening
the form.

If the user has updated any existing records, things fall apart on
subsequent "New Record" operations. When they go to add the new
record, all of the text boxes on the form are empty (good), and the
listboxes have no selections (also good) _UNTIL_ they type a single
character in any of the textboxes on the form. At that point, the
listboxes on the form become highlighted (selected) with whatever
values the prior record contained. I doubt this matters, but these
listboxes only become visible after the user clicks the New Record or
Update Record button.

After I do the DoCmd.GoToRecord , , acNewRec, I explicitly clear out
the listboxes so no values are selected. But the instant the user
types a character (KeyPress event) in any text box, the above happens.
What I WANT to happen is for the listboxes to remain unselected until
the user selects something. How can I implement this?

Thanks,
Beth F.
 
B

Beth F.

I found the solution; in case it helps someone else here it is:
On a new record, I was looping through those unbound listboxes and
setting .selected = False, but what I really needed to do was set the
listbox value to null.

Thanks to everyone who posts and answers here. Though I stumbled upon
my own solution this time, the number of times I've been helped by
previous posts is countless.

Beth F.
 

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