pass cell value via excel to access macro

iP_123

Board Regular
Joined
Apr 18, 2016
Messages
99
Hi.
This is probably an unorthodox silly question perhaps but indulge me. Is there a way to reference an access form parameter in my excel macro if I have the parameter displayed in a cell in Excel? So this way it is passed to the Access macro.
So basically the parameters are "[Forms]![form1]![Month]" and "[Forms]![form1]![Year]".

How would I include these two lines in the excel macro?
I am thinking that I can input my value in a worksheet cell like I mentioned above and call that range in the macro and name it accordingly; however, I do not know how to do that!


Code:
Dim MyDatabase As DAO.Database
Dim MyQueryDef As DAO.QueryDef
Dim MyRecordset As DAO.Recordset
Dim i As Integer
Sub Execute_CustRebaccessMcr()
 
    Dim lMsgFilter As Long
    Dim A As Object
 
    ''' Remove the message filter before calling CustRebateMcr.
    CoRegisterMessageFilter 0&, lMsgFilter
 
 Set A = CreateObject("Access.Application")
A.Visible = False
A.OpenCurrentDatabase ("F:\IT DeathofourMi.mdb")
A.DoCmd.RunMacro “sbatequalt"
With MyQueryDef
.Parameters("[[Forms]![form1]![Month]") = Range("C10").Value
.Parameters("[Forms]![form1]![Year]") = Range("C11").Value
 
    CoRegisterMessageFilter lMsgFilter, lMsgFilter
Sheets("User Input").Select
[E16].Select
ActiveCell.Value = Now
[B12].Select

End Sub

Thanks.
Ip_123
[FONT=&quot]
[/FONT]
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,213,546
Messages
6,114,255
Members
448,556
Latest member
peterhess2002

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