Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Call function in VBA (Access 2007)

Call function in VBA (Access 2007)

Scheduled Pinned Locked Moved Visual Basic
csharpdatabaseasp-nethelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    misCafe
    wrote on last edited by
    #1

    Dear developers, I have problem in calling function from module in access 2007. 1. Let's see my code: Public Function insertDB(tblName As String, tblField As String, strValue As String, db As ADODB.Database) Dim Str As String Dim Rst As New ADODB.Recordset Rst.CursorLocation = adUseClient Str = "Insert into" & tblName & "(& tblField &)" & " Values(" & strValue & ")" db.Execute Str End Function Is it the correct function??? 2. How to call this function in the form?? Cheers, Visoth

    Chuon Visoth Angkor Wat - Cambodia asp.net - c sharp beginner

    _ S 2 Replies Last reply
    0
    • M misCafe

      Dear developers, I have problem in calling function from module in access 2007. 1. Let's see my code: Public Function insertDB(tblName As String, tblField As String, strValue As String, db As ADODB.Database) Dim Str As String Dim Rst As New ADODB.Recordset Rst.CursorLocation = adUseClient Str = "Insert into" & tblName & "(& tblField &)" & " Values(" & strValue & ")" db.Execute Str End Function Is it the correct function??? 2. How to call this function in the form?? Cheers, Visoth

      Chuon Visoth Angkor Wat - Cambodia asp.net - c sharp beginner

      _ Offline
      _ Offline
      _Damian S_
      wrote on last edited by
      #2

      It's close to being right...

      misCafe wrote:

      Str = "Insert into" & tblName & "(& tblField &)" & " Values(" & strValue & ")"

      Should be: Str = "Insert into" & tblName & " (" & tblField ") Values(" & strValue ")" Of course, this method needs a little more looking at, as you will need to ensure that your strValue parameter includes single quotes around the string you are inserting (if it's a string). You would call this function from the form perhaps via the On Click event of a button.

      I don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! Booger Mobile (n) - A bright green 1964 Ford Falcon - our entry into the Camp Quality esCarpade!! Do something wonderful - make a donation to Camp Quality today!!

      1 Reply Last reply
      0
      • M misCafe

        Dear developers, I have problem in calling function from module in access 2007. 1. Let's see my code: Public Function insertDB(tblName As String, tblField As String, strValue As String, db As ADODB.Database) Dim Str As String Dim Rst As New ADODB.Recordset Rst.CursorLocation = adUseClient Str = "Insert into" & tblName & "(& tblField &)" & " Values(" & strValue & ")" db.Execute Str End Function Is it the correct function??? 2. How to call this function in the form?? Cheers, Visoth

        Chuon Visoth Angkor Wat - Cambodia asp.net - c sharp beginner

        S Offline
        S Offline
        Steven J Jowett
        wrote on last edited by
        #3

        The function does not actually return anything and therefore should be a sub rather than a functions

        Steve Jowett ------------------------- Real programmers don't comment their code. If it was hard to write, it should be hard to read.

        M 1 Reply Last reply
        0
        • S Steven J Jowett

          The function does not actually return anything and therefore should be a sub rather than a functions

          Steve Jowett ------------------------- Real programmers don't comment their code. If it was hard to write, it should be hard to read.

          M Offline
          M Offline
          misCafe
          wrote on last edited by
          #4

          Can you correct this function for me? What's more, I do not how to write code to call this function too.

          Chuon Visoth Angkor Wat - Cambodia asp.net - c sharp beginner

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups