Opening a Form Erases Data from Table

  • Thread starter Krzysztof via AccessMonster.com
  • Start date
K

Krzysztof via AccessMonster.com

Good Day!!

I have a very wierd problem here.

i have a form that is bound to a table with some bound textboxes, and some
non-bound text boxes, etc... nothing out of the ordinary. but when i open
the form, the bound boxes are blank, and it erases the data in those fields
in that table! it only erases the bound data...

what i am doing -
fairly simple operation...

i have a form that has a listbox of records supplied by the same table (i was
thinking that might be the problem...). the user selects the item they want,
and the clicks a button. then, using the unique key selected, it opens the
bound form where the keys match. now the listbox operation does supply the
correct key, and the form opens the correct record (so i am assuming, since
that is the affected record), I have not a clue what is happening...

some help would be greatly appreciated!!
 
J

John W. Vinson

Good Day!!

I have a very wierd problem here.

i have a form that is bound to a table with some bound textboxes, and some
non-bound text boxes, etc... nothing out of the ordinary. but when i open
the form, the bound boxes are blank, and it erases the data in those fields
in that table! it only erases the bound data...

what i am doing -
fairly simple operation...

i have a form that has a listbox of records supplied by the same table (i was
thinking that might be the problem...). the user selects the item they want,
and the clicks a button. then, using the unique key selected, it opens the
bound form where the keys match. now the listbox operation does supply the
correct key, and the form opens the correct record (so i am assuming, since
that is the affected record), I have not a clue what is happening...

some help would be greatly appreciated!!

Is the listbox *BOUND* - i.e. does it have a Control Source? If so, it's
overwriting whatever was in the record which was displayed on the form at the
time the user selected it. Controls (combos, listboxes, etc.) being used to
search for or select data must be *UNBOUND* - nothing in the control source
property.

If that's not it please post your code.

John W. Vinson [MVP]
 
K

Krzysztof via AccessMonster.com

oooooooohhh, ok, i am going to try that...
and, yes, the listbox is bound by a control source.

that you for your prompt responce!! :)
Good Day!!
[quoted text clipped - 16 lines]
some help would be greatly appreciated!!

Is the listbox *BOUND* - i.e. does it have a Control Source? If so, it's
overwriting whatever was in the record which was displayed on the form at the
time the user selected it. Controls (combos, listboxes, etc.) being used to
search for or select data must be *UNBOUND* - nothing in the control source
property.

If that's not it please post your code.

John W. Vinson [MVP]
 
K

Krzysztof via AccessMonster.com

If Anyone has this problem, hopefully this will help...

i did fix the first problem, and removed the ControlSource. i then populated
the listbox using dao, and a small SQL statement. once that was working fine,
whenever i clicked the button to view the other form, the fields were still
blank, and the data was being deleted.

i later found out that on the Forms 'Form_Load' event, i was setting the text
boxes to null, as a way of "clearing the form". so therefore it was clearing
out way too much.

thanks a bunch..
oooooooohhh, ok, i am going to try that...
and, yes, the listbox is bound by a control source.

that you for your prompt responce!! :)
[quoted text clipped - 11 lines]
John W. Vinson [MVP]
 
J

John W. Vinson

i later found out that on the Forms 'Form_Load' event, i was setting the text
boxes to null, as a way of "clearing the form". so therefore it was clearing
out way too much.

owwww...

Yep. Bringing up a perfectly good record and then erasing it will do that...

If you want to open the form to a blank record for data entry, use

DoCmd.GoToRecord acForm, Me.Name, acNewRecord

in the Load event subroutine instead.

John W. Vinson [MVP]
 

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