Solved

MS Access Control on Form

Posted on 2013-10-24
6
313 Views
Last Modified: 2013-10-30
Hi

I have a form on which I am running a query which uses the value of one of the  form's  controls. This control is a calculated field.

On the first record all seems to work fine but after that it's as it the value is cached.

Thanks
0
Comment
Question by:ronnie10165
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 39596644
Can you be more specific?  ie: provide screenshots, code, queries, control sources etc (or even better - a sample database with any sensitive data masked or removed), so that we get a better picture of what you are working with?

The issue you are dealing with sounds like it boils down to the basic nature of controls... even though a control appears in multiple records, it is still only a single control - not multiple.  So at any given time a control has only one value, which is the value of the underlying field in the currently selected record.

There are a number of workarounds to this, but it is not clear what to suggest without knowing more about your application.
0
 

Author Comment

by:ronnie10165
ID: 39597741
Ok please take a look at the attachment

On form1 I want to look up  field value 2 in table2 where the value is greater than the field value1 in table1 and store the result in value3 in table 1.

[value1] in the expression does not seem to work

Thanks for your help
testing123.accdb
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39597903
Ok -

Look at the rowsource property of your combo box, in SQL view.  This is what you currently have:

SELECT Table2.id, Table2.value2
FROM Table2
WHERE (((Table2.value2)>[value1]))
ORDER BY Table2.[value2];

Open in new window


The way you currently have it set up, the combo box is storing the ID, not the value.  If you want to store the value, change your row source SQL as follows and set the column count to 1:

SELECT Table2.value2
FROM Table2
WHERE (((Table2.value2)>[value1]))
ORDER BY Table2.[value2];

Open in new window


That said...the way you currently have this working is the preferred/best approach 99.9% of the time (store the ID and lookup the text/value on an as-needed basis), and the change you are asking for has its place but in many applications is not the best approach.
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

by:ronnie10165
ID: 39598024
Hi I want to store the ID, the thing is the where part of the SQL statement does not work.

WHERE (((Table2.value2)>[value1]))
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39598193
Boy did I misunderstand your request!  :-)

The issue is that the lists in combos and listboxes (the rowsource property) does not automatically refresh as the user navigates between records - so you see the same list that is populated initially when the form opens, regardless of what record you are on.

You can use VBA to requery the row source when the record changes.

In the form's property sheet, under the Events Tab, click the ... next to On Current and select Code Builder.  Then place a requery statement between the Sub and End Sub lines.  It should look like this when done, replacing "Combo5" with whatever the actual name of your combo is in your application:

Private Sub Form_Current()
    Me.Combo5.Requery
End Sub

Open in new window

0
 

Author Closing Comment

by:ronnie10165
ID: 39613293
Thanks yes that's tested and working. Thanks for your help
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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…
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…
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…

751 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