Open form at specific record

  • Thread starter Tazzy via AccessMonster.com
  • Start date
T

Tazzy via AccessMonster.com

I have a relatively simple database that I use to keep track of appointments
and visits that I make to certain companies and organisations.

One form that I use regularly has the times and dates of these appointments
together with the name of the company etc. I have amended the properties of
the name so that when I double-click on it, the form giving the full details
of the companies opens. However it always opens at the first name on that
form. Is there a way that I can cause the form to open on the record for the
name that I have double-clicked on?

Thanks,

Tazzy
 
K

Ken Snell [MVP]

Yes, you can do this in the OpenForm action. Use the fourth argument of the
action to specify a filtering criterion string for the form that you're
going to open. For example:

DoCmd.OpenForm "NameOfForm", , , "CustomerID = " & Me.CustomerID
 
T

Tazzy via AccessMonster.com

Thank you Ken - I will try this on my return to work on Monday.

I take it that I do this by going into the coding after I have selected 'on
double-click' in the Properties for that particular field. Still a huge grey
area for me as to where I actually put the required text.
 
K

Ken Snell [MVP]

For my reply, I was assuming that you are using VBA code (or macro) to open
the second form. If you're using VBA code (DoCmd.OpenForm), just modify that
code step. If you're using a macro, add the criterion string to the Where
Argument for the macro, but do it this way:

CustomerID = [CustomerID]
 
L

Linq Adams via AccessMonster.com

I think that's also assuming that CustomerID is defined as a Number, is it
not? If it's defined as Text it would have to be

"[CustomerID] = '" & Me.CustomerID & "'"

wouldn't it?
 
K

Ken Snell [MVP]

Linq Adams via AccessMonster.com said:
I think that's also assuming that CustomerID is defined as a Number, is it
not? If it's defined as Text it would have to be

"[CustomerID] = '" & Me.CustomerID & "'"

wouldn't it?

Yes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top