Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access 2007 : using the expression builder

Posted on 2009-07-16
9
Medium Priority
?
854 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 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 800 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 85
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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 1200 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
 

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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

885 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