PDA

View Full Version : Blank Records



JustJerry
04-04-2006, 03:52 PM
I don't even know how to begin asking this, so I'll try to briefly lay out my situation as clear as I can. Basically what is happening is that when I scroll through records via the 'Next' and 'Previous' buttons on my form, I am getting new records inserted into one of my tables.

Main Form (based on Table Main)
Field X (Autonumber)(Primary ID)
Option A (controls which subform to display)
Choice 1
Choice 2

Subform A (based on Table A)
Linked to Main form via Field X

Subform B (based on Table A)
Linked to Main form via Field X


For example, if User selects Choice 1 in the Option A Group box, Subform A is enabled and made visible, Subform B is disabled and hidden.

If user selects Choice 2, Subform A is disabled and hidden, and Subform B is enabled and made visible.

In the Main Form, I have in the 'On Current' event, VBA code that looks at the value in Option A, and displays the correct form. If record is 'New', then both forms are hidden and disabled.

So I created a few test records, as for each record in the Main Form, there can be multiple records for the subforms.

But, for some reason, when I tab through the records on the Main Form, I am getting blank records created in Table A. I do NOT understand why this is happening. Is it because I have two subforms relating to the same table?

Some of the unwanted records in Table A will have the value of Field X(linked field), and some of the records will have a Null Field X.

The reason for the two subforms is that, though they come from the same table, I display different fields depending on the value of Option A that is selected.

At first I was just using the Visible=True/False for the subforms, then I added the Enabled=True/False to see if that would cure the problem, but obvioulsy that was too simple to even work :-)

Any ideas? Am I too vague?

XLGibbs
04-04-2006, 05:18 PM
If your forms are linked to tables it is likely that the movement between records is "updating" them as it goes.

The best way to do what you describe is use a query to get the data into the subform rather than linking it directly to the table. Also if the data is only meant to be viewed, you can set the recordset to be locked and not allow updating of records. Provided the tables also have a primary key, you may be able to use that to avoid new records as well.

wasim_sono
04-05-2006, 01:58 AM
JustJerry

I think you are using switchboard manager and using this u open the form in add mode. If yes then change it by edit mode. you will find all the records.

Regards.


Wasim:beerchug:

JustJerry
04-05-2006, 07:35 AM
Hey XL,

My Main form and both Subforms run off of queries. When I created the subforms, I linked them to show each record of the subform via the Field X. I have one Query for the main form, and seperate queries for each of the subforms.

The Main Table has a primary ID(Field X) as well as the Table A used for the subforms.

The data, in this case, was not meant to be 'viewed' only, as I wanted to be able to move around the records and edit them as needed.

I should add that everything worked fine when I had just one subform. Then when I discovered I needed two forms to show different data only when needed, I added a second subform. It is this subform that is causing the problem for some reason. I know this because on the second subform, there is a field that I set to have a default value, which the first subform didn't have, and I would see that value in all these newly created records.

I guess I'm confused as to why it would create a new record just by moving between the existing records. I'm not 'editing' any of the field values at all.

JustJerry
04-05-2006, 10:06 AM
As an update, I deleted the entire VBA coding of the second subform I created, and the problem went away.

So now I have to figure out what exactly was causing the blanking records to be created in the Coding I inputed

JustJerry
04-05-2006, 10:07 AM
As an update, I deleted the entire VBA coding of the second subform I created, and the problem went away.

So now I have to figure out what exactly was causing the blank records to be created in the Coding I inputed