Solved

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

Posted on 2014-04-29
5
55 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
[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
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

730 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