Code to Open a form directly from query output

  • 10 years ago

    Hi

    Can anyone please help? I'm reasonably profficient at VBA for Excel but a colleague has asked me to help with a problem concerning VBA for Access - and I'm struggling. Problem is this.

    I have database - DatabaseA

    from this Database I have a Form - FormB - which shows me all the data relating to any record from DatabaseA

    then I have a Query - QueryC which selects some records from DatabaseA - based on any given criteria.

    After I run the query I want to be able to select one of the records (by doubleclicking)on the record name from the query (can pick up the name ok using vb)

    then to close the query - (I can do this too)

    then open FormB at the record I've selected (doubleclicked from the Query) - I can open the form but I cant get the record loaded onto it for some reason

    please can anyone help?

    thanks

     

  • 10 years ago

    Hi,

    Not sure if my last reply reacherd the system yet. The way I have done it before is to place the Query C into a  form which is set to continuos(?). In one of the fields of this form place a click or double click event. This event when activated will capture the record inforamtion, then update the underlying SQL statement for Form B, refresh and your done. The clever part of this is to design the form for the query C well enough so it looks like a normal datasheet.

    I have done this as a subform before, the users are just impressed and more brownie points for you. If the query has criteria, then just build these before hand (thats why I use it a subform on the main form.

     

    Hope this helps

    Alan Hill

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“My definition of an expert in any field is a person who knows enough about what's really going on to be scared.” - P. J. Plauger