Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset and ![Field] 2

Status
Not open for further replies.

CharlesFS

Technical User
Dec 14, 2008
39
BR
How make "strsql" string get value of field in the current recordset line.

I tryed this:

Code:
Dim Rst As DAO.Recordset
Set Rst = CurrentDb.OpenRecordset("ConsultaIPE")
Dim Link As Variant
With Rst
  .MoveFirst
  While Not .EOF
   Dim strsql As String
...          
       strsql = "INSERT INTO CONSULTAIPE2 (link, documento) VALUES ([red]!Link , !documento[/red]);"
       DoCmd.RunSQL strsql
...     
       
    .MoveNext
  Wend
End With
 
You are feeding the literals, you need the values, i e

[tt]... VALUES (" & !Link & ", " & !documento & ")"[/tt]

Now, this if for numeric fields, if the fields are text, you need text delimiters (for instance single quotes)

[tt]... VALUES ('" & !Link & "', '" & !documento & "')"[/tt]

or dates, where you'd need something more, check out Allen Brownes page
Roy-Vidar
 
Assuming that both field aren't defined as numeric in CONSULTAIPE2:
Code:
strsql = "INSERT INTO CONSULTAIPE2 (link,documento) VALUES " _
 & "('" & Replace(!Link, "'", "''") & "'" _
 & ",'" & Replace(!documento, "'", "''") & "')"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top