vba - Get the last date before selected date from ACCESS in Excel -


i have access database date column in table, dates sorted there can missing dates. problem latest date before input date. example managed solve problem in excel sheet {=max(if(a1:a10<=c1,a1:a10,0))} formula, have database large amount of data , need call db formula.

i tried write code, doesn't work. don't why ? me problem ? thanks.

public function getdatedb(tbl string, colmn string, dt string) variant  dim db database dim rs recordset dim dbfile  dbfile = application.thisworkbook.path & "\mydatabase.accdb"  set db = dbengine.opendatabase(dbfile) set rs = db.openrecordset("select max(" & colmn & ") maxdate " & tbl & " maxdate <= #" & format(dt, "m\/d\/yyyy") & "# ", dbopendynaset)  if rs.recordcount > 0     rs.movefirst     getdatedb = rs!maxdate end if  end function 

as far consider, need replace ... maxdate <= ... ... maxdate < .... (just delete equals-symbol)

when search <= in cases input date.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -