How to add data directly in SQL using Pass Through Query (1 Viewer)

usertest

New member
Local time
Today, 16:09
Joined
Oct 17, 2023
Messages
19
Hello,
Below is the code where I want to make it using pass through query.
Can anyone guide me how can i achieve the below logic and implement using PTQ?

Code:
Dim rs1 As New ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT * FROM SQLTABLE;"
rs1.Open strSQL, DC.ASSIGNMENT_DATA, adOpenKeyset, adLockOptimistic

rs1.AddNew
rs1("ID") = Me.ID
rs1("FIRST_NAME") = Me.FIRST_NAME
rs1("LAST_NAME") = Me.LAST_NAME
rs1("CURRENT_MEMBER") = True
rs1("DATE_ADDED") = Date
rs1("REASON_ADDED") = "3"
rs1("PREFERRED_FULL_NAME") = Me.PREFERRED_FULL_NAME
rs1("EMAIL_ADDRESS") = Me.EMAIL_ADDRESS
rs1("DIRECT_DIAL") = Me.DIRECT_DIAL
rs1.Update
rs1.Close
 
You would build an append query:

INSERT INTO TableName(Field1, Field2...)
VALUES(Value1, Value2...)

make that the SQL of the pass through query and then execute it.

 
Is there some reason that you are not using a bound form?
 

Users who are viewing this thread

Back
Top Bottom