what's wrong with this statement?
adobau.RecordSource = "SELECT * FROM tblbau WHERE year(Bau_datum) => " & Jahr_beg & "AND year(Bau_datum)<= " & (Jahr_beg + intyears)

try Between function...
instead of >=,<=...

" & Jahr_beg & "AND
no space must be
" & Jahr_beg & " AND
how to debug:
make a variable with the string ex:
sqlstr= "SELECT * FROM " & foo
place a breakpoint after that
goto watch window
print the sqlstr (by ?sqlstr)
now you have the full string
(if foo="MYTABLE" then
you have
SELECT * FROM MYTABLE
now copy that and
run the that sql command from the IDE of database
(example: if database is MSACCESS open the mdb
create new query
goto sql mode
paste the sql command
and run it.
MSACCESS will comply with more explanations)

I did >= instead of => and now it works, thanks for your help, I might still try the "between" it's probably more correct

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.