Running Access Form from Excel VBA -


i using excel 2013 , access 2013. access query has form takes2 inputs, "start date" , "end date", , runs macro in access. there way can use vba input "start date" , "end date" excel , run form in access? here have tried, error saying "the action or method invalid because form or report isn't bound table or query"

sub runaccessquery()  dim strdatabasepath string dim appaccess access.application dim startdate date dim enddate date  startdate = thisworkbook.sheets("sheet1").range("b2").value  strdatabasepath = "access database path" set appaccess = new access.application appaccess     application.displayalerts = false     .opencurrentdatabase strdatabasepath     .docmd.openform "inputform", , , "start =" & startdate     '.quit end set appaccess = nothing  thisworkbook.refreshall msgbox ("data has been updated")  end sub 

this form looks like. click me runs macro, first text box holds variable "start" , second 1 holds variable "end"

enter image description here

since assume form has no recordsource, , controls unbound, following should avoid error you've encountered:

sub runaccessquery()  dim strdatabasepath string dim appaccess access.application dim startdate date dim enddate date  startdate = thisworkbook.sheets("sheet1").range("b2").value  strdatabasepath = "access database path" set appaccess = new access.application appaccess     application.displayalerts = false     .opencurrentdatabase strdatabasepath     .docmd.openform "inputform"     .forms("inputform").start = startdate     '.quit end set appaccess = nothing  thisworkbook.refreshall msgbox ("data has been updated")  end sub 

however, still nothing more open form , set start date, , closes access after.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -