Populate Excel UserForm textbox with data from MS Access form


I have an Excel file here that contains a UserForm object containing multiple textboxes and comboboxes that I would like to auto-fill with data from MS Access if I can. Specifically, when I'm viewing a particular record within an Access form, I'd like to click a button that launches the Excel application/workbook and references specific textbox and combobox items on the UserForm, populating them with values from that particular database record currently being viewed in MS Access.

From with Excel VBA, I can currently do this with the following code.
UserForm1.TextBox1 = "This is test data."

Open in new window

Just trying to get from MS Access to MS Excel.

Is this possible? Any help or suggestions would be appreciated!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
The easiest approach: Export the data to a sheet and read in Excel.

Public Sub testExcel()

  Dim ea As Object 'Excel.Application
  Dim ew As Object 'Excel.Workbook
  Dim es As Object 'Excel.Worksheet
  Set ea = CreateObject("Excel.Application")
  Set ew = ea.Workbooks.Add '(ATemplateFileName)
  ea.DisplayAlerts = False
  ea.Visible = True

  Set es = ew.Sheets.Add
  es.Name = "TEST"
  es.Range("A1").Value = "Attribute1"
  es.Range("B1").Value = "Value1"
  es.Range("A2").Value = "Attribute2"
  es.Range("B2").Value = "Value2"
  es.Range("A3").Value = "Attribute3"
  es.Range("B3").Value = "Value3"

  If Not ea Is Nothing Then
    ea.DisplayAlerts = True
    ea.Visible = True
  End If

  Set es = Nothing
  Set ew = Nothing
  Set ea = Nothing

End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Try something along these lines:
Sub Demo()
    Dim oApp As Object
    Set oApp = CreateObject("Excel.Application")
    oApp.Workbooks.Open "full file path", True, False
    oApp.UserForm1.TextBox1.Text = txtAccessTextBox
    oApp.Visible = True

    Set oApp = Nothing
End Sub

Open in new window

Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.