excel - Calling a sub from another using date variables in ACCESS vba -


i trying invoke sub sub in access , keep getting "compiler error byref argument mismatch. understand says variable passing not match 1 specified in called sub. here code. have variables firstdayofstartmonth , firstdayofendmonth defined dates , passing them second proc deletecurrentdata(startdate date, enddate date).

any appreciated.

sub loaddatafromexcel()  dim monthname1, monthname2 string  dim startmonth, endmonth, curmonth   integer  dim thismonday, rptstartdate, rptenddate, firstdayofstartmonth, firstdayofendmonth date      thismonday = date - weekday(date, vbmonday) + 1  rptstartdate = thismonday - 14  rptenddate = thismonday - 10  firstdayofstartmonth = dateserial(year(rptstartdate), month(rptstartdate), 1)  firstdayofendmonth = dateserial(year(rptenddate), month(rptenddate), 1)  call deletecurrentdata(firstdayofstartmonth, firstdayofendmonth)  end sub  private sub deletecurrentdata(startdate date, enddate date) 

i have variables firstdayofstartmonth , firstdayofendmonth defined dates

actually, not quite true!

when you're using declaration

dim thismonday, rptstartdate, rptenddate, firstdayofstartmonth, firstdayofendmonth date 

only firstdayofendmonth type of date, other values variant. try use declarations instead

dim thismonday date, rptstartdate date, rptenddate date, firstdayofstartmonth date, firstdayofendmonth date 

this fix problem.

p.s. same thing

dim monthname1, monthname2 string 

and

dim startmonth, endmonth, curmonth   integer 

change them

dim monthname1 string, monthname2 string 

and

dim startmonth, endmonth integer, curmonth integer 

accordingly


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -