How can I add record in other table

CMontoro

Registered User.
Local time
Today, 14:00
Joined
Mar 26, 2005
Messages
21
There is a form ORDER wich works with table TORDER
One of its text box is NAME

I need insert the the name's data in the table TPERSONAL (other table) , in the field NAMEPER

How can I insert a record in that table ?

Thanks in advance

CM
 
CMontoro said:
There is a form ORDER wich works with table TORDER
One of its text box is NAME

I need insert the the name's data in the table TPERSONAL (other table) , in the field NAMEPER

How can I insert a record in that table ?

Thanks in advance

CM


Dim strFilter As String

strFilter = "INSERT INTO TPERSONAL(NAMEPER) " _
& "SELECT name " _
& "FROM TORDER " _
& "WHERE orderID = " & Me!ORDER!orderID

CurrentDb.Execute strFilter, dbFailOnError

This was for access 2000.

My experience is that it is best to enclose these procedures in their own error handlers. That is: Begin the whole thing with:

On Error GoTo err_thisInsertThing

and finish with:

Exit_thisInsertThing:
Exit Sub

Err_thisInsertThing:
etc......
 
1) You shouldn't have a textbox named "Name"; it is reserved and will cause problem.

2) You also can try something like this...

Code:
Dim dbs as DAO.Database
Dim rst as DAO.Recordset

Set dbs= CurrentDatabase
Set rst(YourtableOrQueryhere)

With rst
     .Addnew
     .Field1= Me.Textbox1
     .Field2= Me.Textbox2
     .Field3= Me.Checkbox
     .Update
End With

Set rst= Nothing
Set dbs= Nothing

This is off the top of my head so there may be some errors.
 

Users who are viewing this thread

Back
Top Bottom