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
Post a Comment