Solved

Refer to a calculated control in a subform from a recordset.

Posted on 2014-04-29
5
53 Views
Last Modified: 2016-05-29
Hello Experts. I have an issue which is out of my area of expertise and could really do with some expert help, so thanks in advance:

I have some code which is meant to update some values in a subform. The recordset I am using must refer to the values in a calculated control on my subform - and this is what I am struggling to do.

How do I refer to my calculated control from with a recordset?

This is my current code:

        Dim rsc As DAO.Recordset
        Set rsc = [frmAllocateToBuildComponentSub].Form.RecordsetClone
        rsc.MoveFirst
        Do Until rsc.EOF
        rsc.Edit
        rsc!stockcheckqty = *** SOMETHING LIKE THIS : stockcheckqty - mycalculatedcontrol) ***
        rsc.Update
        rsc.MoveNext
        Loop
    

Open in new window



If it helps here is a snip of my button and the controls I want to refer to:

RecordSet and Calculated Control
0
Comment
  • 2
  • 2
5 Comments
 
LVL 27

Expert Comment

by:MacroShadow
ID: 40029867
Assuming you have controls named stockcheckqty and mycalculatedcontrol this should work:
rsc!stockcheckqty = stockcheckqty - mycalculatedcontrol

Open in new window

0
 

Author Comment

by:Computer_Support_Norwich
ID: 40029909
Hi... thanks for the reply.

I already tried that but it won't work. I assume because the button is on the parent form and the controls are on the subform. The code runs but sets all my values to ZERO and I have previously identified it's looking on the parent from when I use that code.
0
 
LVL 27

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 40029949
Oh i see:
rsc!stockcheckqty = Forms![main form name]![subform control name].Form![stockcheckqty] - Forms![main form name]![subform control name].Form![mycalculatedcontrol]

Open in new window

0
 

Author Comment

by:Computer_Support_Norwich
ID: 40063875
Hi - sorry for delay in responding, this is a project I only pick up once every couple of weeks. I will check it out and come back to you.
0

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Office 365 home questions 7 65
SQL - Cumulating field values to one field 5 19
zero pad a access form field 2 15
Access: Retrieving Current Month's Orders for Invoice 6 27
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

813 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

18 Experts available now in Live!

Get 1:1 Help Now