use of OR in expression

fuglyjowls

Registered User.
Local time
Today, 15:40
Joined
Sep 21, 2005
Messages
55
Hi

I have a form which is opened by two methods - one from a command button on "frmcontacts" form and two from double-click on "ordersummary" form. At the moment there is a field which populates from the command:

=[forms]![frmcontacts]![surname] which is fine if you enter it from "frmcontacts" however I want it to also populate from "ordersummary" with the same info. I thought it would be as simple as changing the command to:

=[forms]![frmcontacts]![surname] OR [forms]![order summary]![surname] but this doesn't seem to work.

Can anyone help?

Thanks
 
Do you have this in the 'Default Value' for the form?
 
no it's the control source
 
So when you open the second form, you simply want to display the surname off one of the first forms and not store it anywhere?
 
Yes that's right - it's stored in frmcontacts which is where it is getting the info from if you click on the command button
 
So in the code that opens the second form, simply do something like:

forms!MySecondFormName!MyCommonTextBox = me!SurName

????
 
So in the code that opens the second form, simply do something like:

forms!MySecondFormName!MyCommonTextBox = me!SurName

????
 
thanks but when I change it it then doesn't work from the first form.
 
The me!SurName should get picked up from which ever form is calling the second form. You did add the line to both primary forms didn't you?
 
maybe I didn't explain this properly. Form1 has a command button to open Form2. Form3 has a double click to open Form2. On Form2 there is a field in the header which says:

=[Forms]![Form1]![surname]

It is this which I am trying to change not anything on Form1 or Form3. so I want it to take it from Form1 if it is opened from Form1 or from Form3 if it is opened from Form3.

Does this make sense?
 
Sure. You have that line in the control source. Take it out and don't have anything there. Then in the code in form 1 that opens form2, do the code I suggested. The do the same for form3.

???
 
Thanks for help - I have changed the code for form1 but on form3 it is a macro to open form2 - where do I put the code? I tried putting it in the where condition (which already has a code in) but it doesn't work.
 
You can re-write most macros as code so I would convert this from a macro to code. What all does the macro do? (Step by Step)...
 
sorry I should explain that I am not a programmer and only know the basics of access most of which I have picked up as I go along. I have never written anything in code as I don't know how. That's why I used a macro as its the only way I know of doing things. The macro is opened when you double-click the surname field in form3. It opens up form2 and it has a where condition of

[order no]=[Forms]![order summary]

where order no is the unique key and order summary is the name of form3.

That's all
 
Do you know how to change an event from executing a macro to executing a block of code?
 
Then you should be able to replace the macro with something like:

DoCmd.OpenForm "Employees", , ,"LastName = 'King'"

Make sense?
 
but how do I get it to automatically open the record I've just clicked on rather than specify an actual surname?
 
Hum...We're 18 posts into this thread and I only making you more confused... :eek: :o

Can you post a small sample of the database with the stuff in question?
 
I don't think it's possible as there are all sorts of permission/security levels which I don't know how to take off.
 

Users who are viewing this thread

Back
Top Bottom