Results 1 to 4 of 4

Thread: Require Method VBA SQL

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2010
    Posts
    32

    Require Method VBA SQL

    Hello,
    I have two tables, Dealerdata and dailiytab
    dealerdata has dealerid, dealername, marketingguy feilds
    dailydtatab has dealerid, dealername, date feilds

    i want to enter data in daily tab using a form
    i have a text object which takes input for dealerid
    it matches with the dealerdata table and inserts dealerid , dealername and date(current) in the dailydtatab table
    Code:
    Private Sub adddelid_Click()
    Dim r1 As Object
    Dim r2 As Object
    Dim sqla As String
    
     
     
    Set r2 = CurrentDb.OpenRecordset("SELECT dealerid FROM dealerdata WHERE dealerid = ' " & Me.delident.Value & "'")
    sqla = r2.Fields![dealerid]
    Set r1 = CurrentDb.OpenRecordset("SELECT * FROM dailydtatab WHERE FALSE")
    
    r1.AddNew
    r1.Fields![dealerid] = r2.Fields![dealerid]
    r1.Fields![dealername] = r2.Fields![dealername]
    
    
    r1.Update
    r1.Close
    Set r1 = Nothing
       
    End Sub
    kindly help me with a code

    i am getting a 3021 error
    Attached Images Attached Images  
    Last edited by cycleinmars; Feb 9th, 2012 at 12:53 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width