Import from access query (adding input boxes to satisfy the rilte requirements)

richertt

New Member
Joined
Sep 1, 2018
Messages
14
Hello all,

First off, the experts on this site have been so helpful in my VBA endeavours. I can't thank you enough. Now, my next challenge.....

I have been using the following code to pull data from various queries within my database....

Sub Get_Data ()


' pull data from the database


ActiveSheet.Name = "-Sheet1-"


Cells.Select
Selection.Delete Shift:=xlUp
Range("A1").Select


Dim dbs1 As DAO.Database
Dim rst1 As DAO.Recordset
Dim i1 As Long
Dim wsh1 As Worksheet

Set dbs1 = DBEngine.OpenDatabase("\\cherubim\RW Shares\MiniMRP DataMine\MiniMRP Data Mine.accdb") 'select the database
Set rst1 = dbs1.OpenRecordset("Ship List1") ' select the query
Set wsh1 = Worksheets("-Sheet1-")

For i = 0 To rst1.Fields.count - 1
wsh1.Cells(1, i + 1).Value = rst1.Fields(i).Name
Next
wsh1.Range("A1").Resize(ColumnSize:=rst1.Fields.count).Font.Bold = True
wsh1.Range("A2").CopyFromRecordset rst1
rst1.Close
Set rst1 = Nothing
dbs1.Close
Set dbs1 = Nothing


It has worked out great until today. I now need to pull data from a couple of queries in Access that have inputs that need to be filled in before the query runs. How could / would I modify the above code to allow me to have input boxes to satisfy the Access query when my macro is run in Excel?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,223,746
Messages
6,174,258
Members
452,553
Latest member
red83

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top