View Full Version : one form two tables


aspxkid
12-15-2007, 08:42 PM
I have a form where the no. of fields is more that 255. say 320. So i have created 2 tables, TblX and TblXOne. I am using sql server 2000 as the backend. i have an autogenerated ID in TblX and X_ID column in TblXOne.
255 cols are stored in Tblx table which is the max. so remaining cols of the same form are stored in TblxOne table. I use X_ID as the primary key of TblXOne table. X_ID is same as ID.
I am importing from an excel the data into the form fields, doing some calculation in the form fields and then saving them to the database.
While i am doing this, i get an error message: Cannot find primary key of TblXOne. How ishould be able to add records into both tables..
Some one pls help..

Rabbie
12-16-2007, 01:45 AM
I think you may need to look at your basic design. Have you looked at data normalisation. 320 fields per record seems to be on the high side. In general Access/Database tables should be tall and thin. I see you are importing data from an Excel spreadsheet where it is common to have much wider(more columns) than in database tables. To get the best out of relational databases they need to be designed correctly.

aspxkid
12-17-2007, 08:21 AM
thanks for your reply.

The prob is it is an 5 year old app where i am doing some changes. Because of the limited no of cols in the database table definition, i had to use second table .
So apart from changing the design of tables, how to handle the problem .
it will be a great help from ur side.

Pat Hartman
12-17-2007, 05:47 PM
You aren't going to be able to create a query with more than 255 columns so you won't be able to create a recordsource that you can use to add rows to both tables at once. Assuming that the spreadsheet has a unique identifier for each row, use that as the primary key for both tables.

I should warn you as the others have that what you are doing is wrong, wrong, wrong. Importing a spreadsheet into a relational database doesn't make it a table. It is still a spreadsheet but now it is in a relational database where there are no spreadsheet functions available so you will have nothing but code ahead of yourself trying to make this work. Normalize now to get the best results from Access.