vba - Displaying account operations by dates -


i need verify operations done in account @ particular period of time asking user enter account number , date range, each time run have error "type mismatch"

here code:

private sub cmdsearch_click()     call search end sub  sub search()     dim strcriteria, strcount, task string      me.refresh     if isnull(me.compte_hist) or isnull(me.date_deb) or isnull(me.date_fin)         msgbox "s'il vous plaƮt assurez-vous que tous les champs sont remplis", vbinformation, "date range required"         me.compte_hist.setfocus     else         strcriteria = "([date_operation]>= #" & me.date_deb & "# , [date_operation] <= #" & me.date_fin & "#)"         strcount = "[compte]=#" & me.compte_hist & "#"         task = "select * operations operations  (" & strcriteria & ")" , " (" & strcount & ") order [date_operation]"          docmd.applyfilter task     end if end sub 

try this:

strcriteria = "([date_operation]>= #" & format(me.date_deb, "mm\/dd\/yyyy") & "# , [date_operation] <= #" & format(me.date_fin, "mm\/dd\/yyyy") & "#)" strcount = "[compte]=" & me.compte_hist task = "select * operations (" & strcriteria & ") ,  (" & strcount & ") order [date_operation]" me.recordsource = task 

also can apply filter only:

strcriteria = "([date_operation]>= #" & format(me.date_deb, "mm\/dd\/yyyy") & "# , [date_operation] <= #" & format(me.date_fin, "mm\/dd\/yyyy") & "#)" strcount = "[compte]=" & me.compte_hist task = "(" & strcriteria & ") ,  (" & strcount & ")" me.filter = task me.filteron = true 

if account number not numeric, use quotes:

strcount = "[compte]='" & me.compte_hist & "'" 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -