Solved

MS Access Control on Form

Posted on 2013-10-24
6
315 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 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