Add new record

J

jerry

Hallo everyone,

I have a form with unbound textboxes that forms a record,how can I add a
new record of unbound textboxes afterI have update the first record?
Can anyone help me please?
 
A

Alex White MCDBA MCSE

Hi Jerry,

Because all your controls are unbound, I am guessing that the form is
unbound too,

what you need is a button e.g. 'save' and in the click event for the button
the following

** Air code **

Dim adoTest As New adoDB.Recordset
With adoTest
.Open "Select * from YourTableName", CurrentProject.Connection,
adOpenKeyset, adLockOptimistic
.AddNew
.Fields("first1").VALUE = Me.Text1.VALUE
.Fields("second1").VALUE = Me.Text2.VALUE
.Update
.Close
End With

' you will want to clear the textboxes at this point to start again

me.Text1.value = ""

......
 
A

adsl

jerry said:
Hallo everyone,

I have a form with unbound textboxes that forms a record,how can I add a
new record of unbound textboxes afterI have update the first record?
Can anyone help me please?
 
A

adsl

Alex White MCDBA MCSE said:
Hi Jerry,

Because all your controls are unbound, I am guessing that the form is
unbound too,

what you need is a button e.g. 'save' and in the click event for the
button the following

** Air code **

Dim adoTest As New adoDB.Recordset
With adoTest
.Open "Select * from YourTableName", CurrentProject.Connection,
adOpenKeyset, adLockOptimistic
.AddNew
.Fields("first1").VALUE = Me.Text1.VALUE
.Fields("second1").VALUE = Me.Text2.VALUE
.Update
.Close
End With

' you will want to clear the textboxes at this point to start again

me.Text1.value = ""

.....


--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk
 
A

adsl

Alex White MCDBA MCSE said:
Hi Jerry,

Because all your controls are unbound, I am guessing that the form is
unbound too,

what you need is a button e.g. 'save' and in the click event for the
button the following

** Air code **

Dim adoTest As New adoDB.Recordset
With adoTest
.Open "Select * from YourTableName", CurrentProject.Connection,
adOpenKeyset, adLockOptimistic
.AddNew
.Fields("first1").VALUE = Me.Text1.VALUE
.Fields("second1").VALUE = Me.Text2.VALUE
.Update
.Close
End With

' you will want to clear the textboxes at this point to start again

me.Text1.value = ""

.....


--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top