How to open recordset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have to write a code where I have 2 tables table 1 and table 2 which are
similar structures. I got to insert only those records which are not found
based on a key field called rec_isn

So I am trying to do something like this in access forms coding.. but it
dosent work... plz help...

Gives me type mismatch on set rs = "select ..."

Private Sub CmdImpDB_Click()
Dim SQL As String

Dim rs As Recordset
Dim rs1 As Recordset
Set rs1 = "select * from tbl_wc_wcands_kpwcmatch"

Do While rs1.EOF = False
SQL = rs1!REC_ISN
Set rs = "select * from kpwcmaster,tbl_wc_wcands_kpwcmatch where
rec_isn = '" & SQL & "'"
If rs.EOF Then
DoCmd.RunSQL "insert into kpwcmaster select * from
tbl_wc_wcands_kpwcmatch where rec_isn='" & SQL & "'"

End If
rs1.MoveNext
Loop


End Sub

Thanks
Madhuri
 
Check Access VB Help:

1. For DAO Recordset: the OpenRecordset Method.

2. For ADO Recordset: the Open Method of the Recordset Object or the Execute
Method of the Connection Object / Command Object.

There are plenty of sample codes in these Help topics (which should be your
first source of information).
 
Back
Top