Results 1 to 9 of 9
  1. #1
    ryoka012 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    4

    Create a Insert into From scratch for newbie


    Hi,

    Can anyone put me to the right direction in creating a vba in access
    i have sample vba in click event using command button.

    Private Sub cmdSaveRecord_Click()
    Dim daDb As DAO.Database


    Code:
    Set daDb = OpenDatabase("J:\ContainerVerification.accdb")
    daDb.excute = "insert into CLEARANCE (FName,LastName)" _
                             & "values(txtfname,txtLastname);"

    what are the missing syntax in my code.

    Thanks.


    End Sub

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Where do txtLastname and txtFname get values? Where are they Dimmed?

    You will probably need something like this - if these are controls on your form.
    "insert into CLEARANCE (FName,LastName)" _
    & "values('" & txtfname & "','" & Me.txtLastname & "');"

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Plus it's Execute, not excute.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    ryoka012 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    4
    i will get it on a textbox..

  5. #5
    ryoka012 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    4
    I have an error saying.

    Compile error:

    Argument not optional

    it has been pointing on daDb.Execute

    Can anyone point me on the right direction.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Remove the = sign and try it.

    Google ms access db.execute

  7. #7
    ryoka012 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    4
    I have an error saying.

    Compile error:

    Expected user:defined type, not project

    it has been pointing on dim msdb as database

    Can anyone point me on the right direction.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try

    dim msdb as DAO.database
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    ryoka12,

    Please show us your latest code.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Create table with the Insert Into
    By iscinar in forum Queries
    Replies: 3
    Last Post: 08-29-2013, 10:16 AM
  2. Questionnaire DB from Scratch
    By jomby in forum Database Design
    Replies: 4
    Last Post: 05-18-2012, 01:20 AM
  3. Help w/ DB from scratch.
    By ellixer in forum Database Design
    Replies: 9
    Last Post: 11-30-2010, 10:44 AM
  4. Replies: 1
    Last Post: 02-10-2010, 12:39 AM
  5. Replies: 1
    Last Post: 11-17-2009, 06:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums