Solved

Access 2007 : using the expression builder

Posted on 2009-07-16
9
836 Views
Last Modified: 2012-06-21
hi,
im using access 2007,
i have a sub form with fields "A" and "B" on it.
i want that after each change of value of "A", "B" will recivethe new value of  "A".
i managed doing it by writing a simple code, but i wish to know if there's a way to do so using the "Expression builder"?
i tried what to me seemed the obvious way:
after update of A : [B]=[A]
but thats not working.
is there a way?
thanks
0
Comment
Question by:Or_A
  • 4
  • 3
  • 2
9 Comments
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 200 total points
ID: 24868466
Did you do this in the form's Code Module? The code for what you want is very simple:

Sub A_AfterUpdate()
  Me.B = Me.A
End Sub

I'm not sure how you'd do this with the Expression Builder ... I haven't used it for quite some time. However, there are many choices in the listboxes and such, and one of those choices allows you to choose the fields on the object you're working with. This would be where you'd locate those items. The EB is not very intuitive, however, and the code produced by it can sometimes be very arcane and difficult to follow. Learn the basics of VBA and you'll be waaaaaay ahead of the game.
0
 

Author Comment

by:Or_A
ID: 24868513
thanks for the comment,
as i said, i managed doing this using a VBA code. im allready familiar with VBA.
but i want to know if there's a way to do so in the arcaic Expression Builder...
0
 
LVL 84
ID: 24868532
As I said: I'm not entirely sure, nor am I clear as to why you'd want to use the Expression Builder if you're comfortable with VBA. That's a serious step back.
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 300 total points
ID: 24884648
If I am understanding your question correctly...
The Expression builder cannot "Code" anything:
<after each change of value of "A", "B" will recivethe new value of  "A".>
...If that is what you are asking.

(Can I ask, are you asking this out of curiosity or necessity?)

For example, If you select the expression builder from the change event of a control and wrote this:
If [Use Expression Builder to point to Student One Control]= "Jeff" then
    [Use Expression Builder to point to Student Two Control]="Bob"
end if
...You will get an "Invalid Syntax" error.

You can use it to "help" build your code, by "Building" the references to an Object and pasting it into your VBA code,... which is what it is designed to do.

The key word here is: "Expression" builder.
If you want to build code, use the "Code" builder.
;-)

Or perhaps I am not understanding something.
Can you provide a clear, complete example of something you coded that you want to duplicate with the expression builder?

JeffCoachman
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Closing Comment

by:Or_A
ID: 31605056
thanks
boag - i asked because i have a form with many controls in which i wanted to use the "after change" event to update other controls. (not 'if then' sentence as you suggested, but just copy the value to other control)
but you say that it's impossible, so i'll just use VBA code...
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24887066
I never said it was "Impossible"
I never like to speak in absolutes.
I will only go as far as saying that I, personally, have not ever seen this being done.
;-)

...so, out of curiosity, I tried it.

If you use the Expression Builder on the Change event of a TextBox named txtA, you will get something like this:
    =[txtB]=[txtA]
(Which is exactly what the code is, BTW ;-) )
When the Change event for that textbox fires, ...<Drumroll>.... nothing happens.
:-(


JeffCoachman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24887101
... But I am still curious as to why you wanted to do this, as opposed to just using code (as LSM stated)
?
0
 

Author Comment

by:Or_A
ID: 24887333
just thought that it will be more sipmlify to use this kind of short writing (and fact is - you tried simple =[txtB]=[txtA] code) to do it, as i have lots of controls to use it. not some kind of special need or i dont know what :) but as i said, im taking all of you two advices and return to where it all began in this world - the VBA window!
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24967034
;-)
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Cross Tab with two column values 7 34
Create Form using Wizard 14 35
Sub Reports 8 23
Conditional lock of one field in  datasheet 9 20
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now