Hello All,
This is my first question in this forum. I have a superform/subform design. When a value changes in the superform, a function is called which which calculate some values, and change it in every row in the subform. I am not able to figure out how to reach every row in the subform. What i need is
i = subform.rowcount
for count = 0 to i
subform.field.value = calc_value
next
any help will be appreciated
Regards
Nanda
4 9237 ADezii 8,834
Recognized Expert Expert
Hello All,
This is my first question in this forum. I have a superform/subform design. When a value changes in the superform, a function is called which which calculate some values, and change it in every row in the subform. I am not able to figure out how to reach every row in the subform. What i need is
i = subform.rowcount
for count = 0 to i
subform.field.value = calc_value
next
any help will be appreciated
Regards
Nanda
- What is the Linking Field between the Parent Form and Child Sub-Form?
- What is the Data Type of this Field?
- What value change in the Main Form will trigger Recalculations in the Sub-Form? What is this Field's Name?
Hi,
Thx for replying. here is the info you requested for
What is the Linking Field between the Parent Form and Child Sub-Form? - It is an autogenerated number called timesheetid. for each master row, there are 1-7 detail rows inthe subform, corresponding to the days of the week. the super form has a field called the week number. when the user enters this the detail form is populated with seven rows, with the first column as weekday name, (mon-sun), second column as the date (for that week, for that day) and then some other columns.
What is the Data Type of this Field? the field in question is the date field
What value change in the Main Form will trigger Recalculations in the Sub-Form? when the week number is changed in the master form, for all rows in the detail form, the date value must change.
What is this Field's Name? date
hope the above was helpful.
thanks
nanda
ADezii 8,834
Recognized Expert Expert
Hi,
Thx for replying. here is the info you requested for
What is the Linking Field between the Parent Form and Child Sub-Form? - It is an autogenerated number called timesheetid. for each master row, there are 1-7 detail rows inthe subform, corresponding to the days of the week. the super form has a field called the week number. when the user enters this the detail form is populated with seven rows, with the first column as weekday name, (mon-sun), second column as the date (for that week, for that day) and then some other columns.
What is the Data Type of this Field? the field in question is the date field
What value change in the Main Form will trigger Recalculations in the Sub-Form? when the week number is changed in the master form, for all rows in the detail form, the date value must change.
What is this Field's Name? date
hope the above was helpful.
thanks
nanda
Here is the basic Code Template. Make the necessary substitutions wherever appropriate. Be advised that you can also accomplish the above via an Update Query and a Sub-Form Requery, but I'll leave that for the SQL Gang. In the AfterUpdate() Event of [txtWeekNumber]: - Dim MyDB As DAO.Database, MyRS As DAO.Recordset, MySQL As String
-
-
MySQL = "SELECT * FROM tblChildTable WHERE [timesheetid] = " & Me![timesheetid] & ";"
-
-
If Not IsNull(Me![txtWeekNumber]) Then
-
Set MyDB = CurrentDb()
-
'Recordset for the Sub-Form
-
Set MyRS = MyDB.OpenRecordset(MySQL, dbOpenDynaset)
-
With MyRS
-
.MoveFirst
-
Do While Not .EOF
-
.Edit
-
MyRS![date] = 'whatever you are updating to. One reason why I went with
-
'code instead of SQL is that I wasn't sure how each
-
'Record would be Updated. I feel this is more flexible.
-
.Update
-
.MoveNext
-
Loop
-
End With
-
End If
-
-
'Requery the Sub-Form to see the fruits of your labor
-
Me![subfChild].Requery
hi,
Thanks for the recordset idea. The following code worked :
TimesheetDetails.Form.Recordset.MoveFirst
With TimesheetDetails.Form.Recordset
Do While Not .EOF
TimesheetDetails!Date = getdateforweeknum(wknum, TimesheetDetails!DayofWeek) ' this is the code that calculates the date
.MoveNext
Loop
End With
Excellent !
Best regards
Nanda
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Laura |
last post by:
Here's the situation:
I'm trying to use an update query to copy data from one row to another.
Here is the situation:
I have 5 companies that are linked to each other. I need to show all 5...
|
by: Steven |
last post by:
OK.. Here's my situation. I have a subform on a parent form. When
the parent form is loaded, the subreport queries data from a table in
the DB. The parent form has a couple of text boxes for data...
|
by: Kelvin |
last post by:
Dear All,
Please help.
Same as subject !!!
|
by: Kelvin |
last post by:
Hi All,
I wrote a program insert new row between rows while the datatable is
looping. It display the error message.
Exception Details: System.ArgumentException: This row already belongs
to this...
|
by: Kelvin |
last post by:
Hi All,
While the existing datatable is looping, I can insert new row into
datatable, but I can't insert it between datarows. All new rows will
inserted into buttom row.
Here is my code. Please...
| |
by: Diva |
last post by:
Hi,
I have a data grid in my application. It has 20 rows and I
have set the page size as 5. I have a Submit button on my
form and when I click on Submit, I need to loop through
the rows in the...
|
by: Krij |
last post by:
Hi!
I have a problem with the following code (behind a button on
frmOrders):
(structure: frmOrders->frmOrderdetails (form with subform))
strPutBack = "INSERT INTO...
|
by: lucazz |
last post by:
I have a main form (not bound to any data source) with a subform based on a query. The subform shows furniture parts according to the criteria specified on the main form. The purpose of the subform...
|
by: pdesh3 |
last post by:
I have created a form where one text box and two command buttons named Search and Clear are present. Under all these fields I am also including a subform which displays all the values stored in...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |