Subform controls: ARGH!
You have completely misunderstood. Add1c is just dummy data for me to work
with.
[Customer] and [address] are the fields I am using to do the search.
[CustomerName] and [address1] are the fields I am searching.
I explained it in my second response (11/23) when I copied the entire code.
Do you understand what I am trying to achieve?
So if I select "Joe Bloggs" and his address, "5 Cedar House", I want to
press the button and find that particular record. As I said, the code I used
for an earlier version worked perfectly fine, but now [address1] is now in a
sub form, NOT on the main form. That is the only difference so I can't see
why the code won't work now.
"Rick Brandt" wrote:
"scubadiver" wrote in message
...
I have tried it when i first opened the form and this is what I get:
[CustomerName]= 'Joe Bloggs' And 5 cedar House = 'Add1c'
I *can* understand why this has happened.
To explain, my earlier version of the db was not properly designed. Each
customer can have more than one address (like a bank has more than one
branch) but I originally decided not to have a 1:m relationship so the
contact information would be in the main for with the customer name.
A part of the code I used (which worked perfectly ok) was the following:
rstClone.FindFirst "[CustomerName] = '" & Me.Cname & "' And [Address1] =
'" & Me.AddrSrch & "'"
The difference is that there are no quotes or ampersands around [Address1].
The ampersands picks up the information within the field rather than the name
of the field itself hence why I am getting
5 cedar House = 'Add1c'
instead of
[address1] = "5 Cedar House"
This suggests to me that I shouldn't have the ampersands in the current code
" & [Forms]![queries form]![Branch Form].[Form]![Address1] & "
If I remove them and re-run it, Access says it is an invalid field name or
expression yet when i look at the evaluation I get:
[CustomerName]= 'Joe Bloggs' And [Forms]![queries form]![Branch
Form].[Form]![Address1] = 'Add1c'
that is what I want.
Actually no, it is not. You want the evaluated expression to contain the value
found at the form reference, not the reference itself. You need the evaluated
expression to be...
[CustomerName]= 'Joe Bloggs' And '5 cedar House' = Add1c
That's assuming that Add1C is a field name. This has been a funny looking
expression from the beginning. Even though the result is the same just about
anyone else would have written it this way...
[CustomerName]= 'Joe Bloggs' And [Add1c] = '5 cedar House'
....with the form expression on the right side of the second = instead of on the
left.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
|