Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data input to DBGrid problem

Status
Not open for further replies.

MLNorton

Programmer
Nov 15, 2009
134
US
I nave a simple one Form program that includes a DBGrid with six Columns. The database is an ADOTable and an Access database. There are only 180 records in the Access database. Three of the fields are fixed in the database. I need to enter data in the remaining three fields. I can enter data in all three fields of the first selected record. When I try to select a second record I get the following message:

“Key column information is insufficient or insufficient. Too many Rows were affected by update.”

I have other programs that use this type of data input that work, What is my problem and what is the solution?
 
seeing the number of threads you already started, i suppose they concern the same problematic database?

The error indicates that the database has not enough info to determine which record needs updating.
It seems to me that you have a DB design problem here.
can you post the table structure and some sample data here?

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
NamesBoth Text
Apt Text
Phone Text
Envcash Text
Check Text
CheckNum Text

NamesBoth Apt Phone EnvCash Check CheckNum
Sherman, Bob CC-105 879-2303
Lanier, Virginia CC-120 569-3824
Burner, Freda CC-212 923-0046
Paganelli, Iowakah CC-224 569-2236
Smiley, Walter CC-301 644-1890
McKnight, Ruby CC-304 451-2419
Krape, Marge CC-311 569-0038
Smith, Connie CC-320 560-8396
Quick, Monty CC-323 923-9702
Marshell, Marilyn CC-401 451-3533
 
You need to add a primary key to the table, Name, Apt and Phone may qualify as the primary key, but you'd be better served by creating an auto increment field and making that your primary key.

A primary key uniquely identifies each record in the table. So no other record in the table can have the same value, or if the primary key is made up of more than one column, than the combination of all those columns must be unique to the table.

Access has an autoincrement field. Basically, you don't have to worry about providing a value for an autoincrement, it automatically selects the next value - incrementing by one for each new record.

The problem you were having was you were providing a value for the last three columns, but the query had no way of distinguishing one row from any other. Thus, if executed, every record would get the values you provided.
 
I tryed to a new field:
Number AutoNumber
and received the following error:
Too many fields defined.
I could not save the changes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top