Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening Current Record in a Linked Table

Status
Not open for further replies.

number2

Technical User
Oct 25, 2001
284
US
I need to open the Current Record in a linked table. I am banging my head against a wall. Here is what I used to open a current record in the same table:

Dim strCriteria As String
strCriteria = "[QME/AME Information]![lastname]=[Forms]![QME/AME Information]![lastname]"
DoCmd.OpenForm "commfrm", acNormal, , strCriteria
DoCmd.Maximize

The linked table is named comm, its form is commfrm

 
I take it the form this code is in is [QME/AME Information], right?

OpenForm passes the criteria to the form being opened, which merges the string in with its Record Source. If commfrm's Record Source is just the [comm] table, this would result in the following SQL statement for commfrm's Record Source:
SELECT * FROM comm WHERE [QME/AME Information]![lastname]=[Forms]![QME/AME Information]![lastname]

That WHERE clause's first part (before the "=" sign) should be the name of a field in the comm table. Instead, here you're telling it to look in the comm table for something called [QME/AME Information]![lastname]. There's no such thing in the table, so you get an error.

To fix it, in the strCriteria assignment statement, change [QME/AME Information]![lastname] before the "=" sign to the name of the column in the comm table that should contain a match for the form field. Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top