View Full Version : Create Query in VB


agehoops
08-08-2007, 08:37 AM
I've generated the SQL string needed for the query, but how do I go about actually creating the new query? I've found various things on the net, namely the CreateQueryDef (I think) but couldn't get it to work. does anyone have the exact code or resource I need?

Thanks

DJkarl
08-08-2007, 08:43 AM
I've generated the SQL string needed for the query, but how do I go about actually creating the new query? I've found various things on the net, namely the CreateQueryDef (I think) but couldn't get it to work. does anyone have the exact code or resource I need?

Thanks

Call CurrentDb.CreateQueryDef("QueryNameHere", "SQL STRING HERE")

agehoops
08-08-2007, 08:53 AM
Hey, thanks. it seems to work but I don't see the Query in the Queries list or doesn't this create it there? If not then that's fine, but How do I get it to actually run the query as it isn't doing that? Thanks

DJkarl
08-08-2007, 08:57 AM
Hey, thanks. it seems to work but I don't see the Query in the Queries list or doesn't this create it there? If not then that's fine, but How do I get it to actually run the query as it isn't doing that? Thanks

It does create it in the queries list, if you had the query list selected while you ran this code press <F5> to refresh the screen, it should show up.

agehoops
08-08-2007, 09:05 AM
Yea just figured that one out now, thanks. Works a treat :)