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!

problems with field names in code

Status
Not open for further replies.

automaticbaby

Technical User
Jan 16, 2002
45
US
I have a form that has a query as the record source. The query combines about 8 tables. Some of these tables have repetative field names, like First Name, Last Name, etc. I have code to open Word and populate bookmarks in Word.

Here's the code:
Code:
.Item("NominatedPerson").Range.Text = FirstName & " " & MiddleInitial & " " & LastName
.Item("CompanyName").Range.Text = Company
.Item("NominatedPerson2").Range.Text = [NominatedPerson].[FirstName] & " " & [NominatedPerson].[MiddleInitial] & " " & [NominatedPerson].[LastName]
The first line comes up blank (no data), the second line, which comes from the same table as the first line, has the correct data and the third line "can't find the field referred to in your expression."

It looks like I'm formatting something incorrectly, but it seems to work on some of the code, but not all of it. I'm using
.[Field Name] where there are conflicts with field names. Should it be something else? I don't open the query in the code because it's already the record source. Should I do that?
 
Partial code listing. If you're refering to, let's say, Firstname on the form, then it should be Me![Firstname]. If it's refering to some recordset you opened, then precede it with the recordset name, rs![Firstname].

I have a major problem with "The query combines about 8 tables. Some of these tables have repetative field names, like First Name, Last Name,"

It doesn't sound like your tables are normalized. If they're not, your database has problems.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top