Infopath and VBA


I have had some great feedback on how to connect a new InfoPath form
to an Access database using the wizards provided.
Now I'd like to fin out how to communicate with Access in Infopath using VBA.

What VBA code (no wizards) would I use to save data from the following three
InfoPath controls to an Access database with matching columns

Text1 (TextBox)
Date1 (Date)
Number1 (Number)
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
Scott McDaniel (Microsoft Access MVP - EE MVE )Connect With a Mentor Infotrakker SoftwareCommented:
I don't use InfoPath, but couldn't you just use standard SQL to do this:

[Assuming you have a reference in InfoPath to the DAO library]
Dim dbs As DAO.Database
Set dbs = DAO.OpenCurrentDatabase("full path to your access db")
dbs.Execute "UPDATE SomeTable SET Col1='" & Me.Text1 & "', Col2=#" & Me.Date1 & "#, Col3=" & Me.Number & " WHERE YourIDField=" & Me.TheRecordIDValue

Set dbs = Nothing

Again, I know little of InfoPath (other than most people avoid it, for various reasons). If your intent is to collect data via email, you're better off either (a) just not doing it, and building a webpage for people to use or (b) using an Excel spreadsheet attached to the email, and processing that when it is returned. I have been involved in projects like this, and we considered InfoPath, but instead went the route of trying to build our own email "form", using HTML email and identifiers/tags in the HTML. It worked _most_ of the time, which is a bad thing in the world of data.
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much for the feedback. I am doing the project for a client who sells medical parts and seems to enjoy Infopath. I am very much an Excel/Access/ person and moved into because a webpage is clearly a much better way of gathering data. I am curious as to why Infopath is used with Sharepoint though. I will post a further question and paste the link below
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.