VickiH said:
This works now, in that if I double-click my form datasheet, it takes
me to the forms contact page with more detailed information; however,
it doesn't take me to the corresponding record, only the first record
in the form database. Both forms (the form datasheet table and the
form contacts detailed form) have a unique field, Contact ID. Here's
what I did, and it doesn't take me to the corresponding record: [snip]
Can you let me know what I'm doing wrong? Thanks!
Your version of the code:
DoCmd.OpenForm "Contacts Form"
WhereCondition = "ContactID=" & .Value
Doesn't match my version:
in that your second line above is not a continuation of the
DoCmd.OpenForm statement. That's what the ", _" at the end of my
version was doing: continuing the statement onto another line.
You should change your code to:
DoCmd.OpenForm "Contacts Form", _
WhereCondition = "ContactID=" & .Value
Incidentally, you must not have the Option Explicit line at the top of
that module, so Access thinks "WhereCondition" in your code is the name
of a new variable. I recommend that you set the option "Require
Variable Declaration" in the VB Editor's Options dialog, and that you go
back to any modules you've already created, including this form module,
and add the line
Option Explicit
in the Declarations section of each module. That will keep Access from
guessing you want to create a new variable when you happen to misspell a
variable name, or when you make a typo like the one above.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)