Solved

MS Access Control on Form

Posted on 2013-10-24
6
307 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
  • 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Back Up Your Microsoft Windows Server®

Back up 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.

Question has a verified solution.

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

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of utilizing SQL Server views 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 Access…
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 …

773 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