Solved

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

Posted on 2014-04-29
5
49 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 26

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 26

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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

14 Experts available now in Live!

Get 1:1 Help Now