PDA

Click to See Complete Forum and Search --> : adding record into database


oriole72
Feb 8th, 2000, 11:41 AM
Okay, Ive recently learned how to make simple databases but I still can't figure out how to create an Add Button that will create a whole new record in my Access Database. Preferably i'd like the user to click the button and all the text fields on the screen become empty and the user can enter the new information into it. If anyone can help, please do. =)

karunakaran
Feb 8th, 2000, 12:00 PM
In the ADD button click event

'clear all your text boxes
text1.text = ""
text2.text = ""
and so on.
or write a procedure to clear all the text boxes and call it

Bigley
Feb 8th, 2000, 05:06 PM
To clear the text boxes if you have them set up as an array

For i = 0 to 9 'where you have 10 text boxes
text(i) = ""
Next

Then when you are happy that the user has entered their data you can use a SQL insert statement to update your database, this statement could be behind a 'Save' command button.

oriole72
Feb 8th, 2000, 07:22 PM
Actually, I was wondering if the Add button could clear all the fields (which has been mentioned how to solve) but instead of having to update the database after the information is entered, but just to have the fields automatically be the new record when you clicked the add button. That way the new record would already be there with nothing for data, which the user would then enter

pardede
Feb 9th, 2000, 05:26 AM
if you're using DAO and datacontrol with bound textboxes, you can just invoke the addnew method of the recordest in the ADD button click event. All bound textboxes will be cleared and a new record is created, all automatically

private sub cmdAdd_click()
data1.recordset.addnew
end sub