Method or data member not found

jbotts

Registered User.
Local time
Today, 04:14
Joined
Jun 8, 2009
Messages
22
I have a form bound to the following query:

SELECT P.*, A.* FROM tblPatientInformation AS P, tblAdmissions AS A WHERE P.PatientID = A.PatientID

Both tables have a field named FundingSource. When I write the following assignment:

Me.P.FundingSource = Me.A.FundingSource

I get the following Compile error:

"Method or data member not found"
 
The fieldnames are strings eg "P.FundingSource"

Because the name has a dot Access tries to parse it on the dot and expects a property or member. You could surround their names with square brackets. However it would probably be better to alias the fieldnames in the query to something unique so they don't have a name that includes a dot.
 
Names for table fields are best created using the letters A-Z and numbers 0-9. Most other characters and spaces just get access confused. There are also many reserved words which cause problems if you use them as field names. See http://allenbrowne.com/AppIssueBadWord.html
for a complete list.
 
Names for table fields are best created using the letters A-Z and numbers 0-9. Most other characters and spaces just get access confused.

Not just Access. If it doesn't confuse the original developer it certainly will confound those who try to maintain the code later.

When experienced developers see a slash it automatically triggers thoughts of dates or division. Ampersands mean concatenation. etc etc Dots and Exclamation marks are especially annoying in names.

There are enough letters and numbers without using special characters in object names.
 
Thanks for the help. I had never used an alias for a field name, and that has solved the problem. ( P.FundingSource AS PFundingSource ) and finally Me.PFundingSource = Me.FundingSource worked.
Thanks again,
jbotts
 

Users who are viewing this thread

Back
Top Bottom