L
LightByrd
Here's a poser for the experienced...
I have created a form whose header allows the user to enter a partspec of a
persons last name so as to identify and retrieve that individual's personal
record.
The entry of the partspec & clicking a cmd button triggers a VB routine
which creates the following SQL statement:
MySQL = "SELECT * FROM [qryFindRec] WHERE [ClientLastName]Like" & Chr(39) &
[LookForRec] & Chr(42) & Chr(39)
(where [qryFindRec] is a query containing enough fields to positively
identify the individual.
and [LookForRec] is the name of the text box control which receives the user
input.)
The SQL statement is then forwarded to the subform contained in the detail
section of the main form via this logic:
Me![frmFindRec_Subform].Form.RecordSource = MySQL
This works! Umm well except for this:
A recordcount showed no records found--although I knew there were several
that matched my test partspec.
Long story short, I had included the key PersonID field in [qryFindRec],
because I needed as a means of retrieving the entire record.
Deleting the ID field from the query solved the problem but then placed the
dreaded #NAME error in its column in the subform. (datasheet view)
I worked around the problem by turning the ID into a string in the query.
RecNo: str(personID)
My question is how come this happened and is there a preferred method of
treating it?
Thanks
I have created a form whose header allows the user to enter a partspec of a
persons last name so as to identify and retrieve that individual's personal
record.
The entry of the partspec & clicking a cmd button triggers a VB routine
which creates the following SQL statement:
MySQL = "SELECT * FROM [qryFindRec] WHERE [ClientLastName]Like" & Chr(39) &
[LookForRec] & Chr(42) & Chr(39)
(where [qryFindRec] is a query containing enough fields to positively
identify the individual.
and [LookForRec] is the name of the text box control which receives the user
input.)
The SQL statement is then forwarded to the subform contained in the detail
section of the main form via this logic:
Me![frmFindRec_Subform].Form.RecordSource = MySQL
This works! Umm well except for this:
A recordcount showed no records found--although I knew there were several
that matched my test partspec.
Long story short, I had included the key PersonID field in [qryFindRec],
because I needed as a means of retrieving the entire record.
Deleting the ID field from the query solved the problem but then placed the
dreaded #NAME error in its column in the subform. (datasheet view)
I worked around the problem by turning the ID into a string in the query.
RecNo: str(personID)
My question is how come this happened and is there a preferred method of
treating it?
Thanks