Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004
    Posts
    14

    Unanswered: Updating Table with VBA

    Does anyone know how to update a table in Access with a line of VBA code?

    As an example...say you have a inputbox that asks for the users name...how can you pass that name into a table with VBA.

    Thanks for the help.

    OM
    Chaci

  2. #2
    Join Date
    Sep 2003
    Posts
    228
    To insert into a table:
    SQLStr = "INSERT INTO [Table]([Number], [Name]]) VALUES (1, "Bill")
    DoCmd.RunSQL SQLStr

    To update an existing record in a table:
    SQLStr = "UPDATE [Table] SET [Name] = """ & Person & """ WHERE [Number] = " & Num
    DoCmd.RunSQL SQLStr

    Beware of minor syntax errors I did this on the way out the door.
    Hope it helps...

    Also be careful not to violate any primary key rules and create dupliates and that sort of thing.

Posting Permissions

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