Ask Your Question

Open query or table from a button [closed]

asked 2016-01-30 09:11:42 +0200

spiralfj gravatar image

When I made a button in form to open form or report, ThisDatabaseDocument.FormDocuments.getByName("Form1").open() ThisDatabaseDocument.ReportDocuments.getByName("Report1").open()

But I can't open query or table same way. How can I do to open query or table from a button?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-08-29 18:25:36.773463

1 Answer

Sort by » oldest newest most voted

answered 2016-02-02 12:05:55 +0200

pierre-yves samyn gravatar image

updated 2016-02-03 18:13:26 +0200


The simple solution is of course to base a form on the table/query...

It may nevertheless be directly open table/query as in the OpenTableQuery.odb attached.

I only use a single procedure for both: I test the name of the button to choose between the table and the query.

note: my source was here.

As Drew said not sure this is THE final answer - but it works


If you want to open a query in design view to give parameters, my suggest is to use a form for parameters input, then update the query as in this FR.MACROS_Base_003_RapportParam.odb


edit flag offensive delete link more


Thanks very much. I tried that Drew's source before but my skills and English is not enough, I failed. Now, I checked OpenTableQuery.odb, It worked.

But there’s just one more thing I need to know. I'd like to open query and type words in criterion each time, so is there any way to open query design view from a button?

spiralfj gravatar imagespiralfj ( 2016-02-02 16:21:55 +0200 )edit

That update-query method worked. Thank you very much for your help.

spiralfj gravatar imagespiralfj ( 2016-02-05 08:46:12 +0200 )edit

Hi @pierre-yves samyn, I tried running your file but when I click the report button on the form I get the error that the types don"t match in the code for the Macro.

cleo27 gravatar imagecleo27 ( 2017-06-20 23:59:54 +0200 )edit

Question Tools

1 follower


Asked: 2016-01-28 18:47:54 +0200

Seen: 1,434 times

Last updated: Feb 03 '16