Solved

Access 2007 : using the expression builder

Posted on 2009-07-16
9
835 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

17 Experts available now in Live!

Get 1:1 Help Now