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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add new record to table

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello,

I have one table(persons). This table consist of four fields: id, name, age, address.
Field id is primary key.

I want programmically make new record in table and add only name. (age and address to leave empty).

Set cmd1 = New ADODB.Command
With cmd1
.CommandText = "INSERT INTO persons (name) VALUES ('" & Me.textboxName & "');"
.CommandType = adCmdText
.Execute
End With

but i get error, that field persons.age cannot be null-lenght string.

So is any way to add only name into table?

Thanks in advance for help.

M.
 
Hi,

I think you have to set the properties of the fields in the table "Persons" to the right ones.

Therefore, go to the design view and change following properties:

Property "required" : no
property "Allow zero length": YES.

Hope this is what you are looking for!!!
 
I'm not sure about this. I thought you wanted to add the person's name, not allow it to be null. It sounds as though the method of getting the name to put in the name field of the new record is not working. How are you doing this? Have fun! :eek:)

Alex Middleton
 
I thought the error was about the address field, sorry.
The field "age" is a number-field?

I don't know how you can allow zero-lenghts in a number-field, but maybe you can always write the number 0 to it?
 
Yes, there must be a value in a numeric field. Simply set the default value to 0 and it should add the records OK. Have fun! :eek:)

Alex Middleton
 
I found one very silly error. So now it is all working.
Thanks anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top