Topics Search

subform record loop in VBA

subform record loop in VBA
Views: 127
I know everybody here squinches at the mentioning of mailmerge so lets forget that

how do I extract values from a subform with the same master field value as the main form.

master and sub tables are linked with an idNumber, so there can by many records in the subForms table with the master tables idNumber

I just want to get all the values (rows) in one field in the subforms table that are displaying, for the master forms current record (current records idNumber)

Im thinking that I have to have some kind of if statment together with a SQL query.

Sorry for double posting but I think my previous post was explained a bit to complicated.
Sponsored Links:

More topics


Loop and update each record in datasheet

I have a bound subform in datasheet format on an unbound form. I need to loop through each record, perform a calculation, update 3 fields on the record, then loop and get the next one, continuing until all records have been updated. How do I do this?

2010 VBA "do while" code in a macro

In Access 2010, want to run perform a "do while" loop in a macro. I understand VBA is the way to do this. So, I think I want to run a VBA script in a macro.

This Macro runs against a Form that has a SubFrom (MainForm named "Expense ID" & SubForm, "Expense"). Macro is initiated by pressing a button.

I would like help with some VBA code showing how to perform the following:

1. Evaluate a field ("Activity") in the first record of Subform ("Expense") against condition "Is not Null".

2. If condition is true, set value of another field ("Post") in the same SubForm record to "1".

3. Move to next record and repeat steps 1 & 2 until all Subform records are evaluated.

4. Return to macro that initiated the VBA script to perform the next action in the macro.

record type for loop

I strongly feel that when looping through records in a record set I should be using a for loop. However I am unable to find a record type, that means I need to add in a superfluous extra line .

While a for loop would automatically increment itself. I'm just trying to use a for loop in a situation it was designed for but I seem do be stuck with a while loop.

For Each Loop help - for each Items in an Order

I want to click on a button that executes code that will loop through each of the items in an order. The order is split into the order header and the order details - the order details are shown within the order form in a subform.

The subform contains all the order items ordered. I want to be able run code from within the order form to carry out an action for allthe items in the subform.

I hoped that using the For Each Loop would be the way forward and that it would be quite straight forward. But I'm struggling to work out defining the Object and the Collection. I guess the Collection is the list of relevant order items and the Object is the specific order item - but I'm struggling to convert this to VBA.

Is the For Each Loop the most appropriate way to solve this?

Loop through subform records

I'm having a dumb moment, but can someone help me to remember how to use the docmd.gotorecord . next record on a subform. I can code it fine to go through the records on the main form but not the subform.

Creating Labels

I'll try and make this as concise as possible!

I have a record with a subform. Within the subform there are, say, 3 individual records. Each record has it's own text field and number required. I want to print labels to a sheet that loops through each record and creates the number of labels required with the text field data, so:

Record 1 DLawson 3
Record 2 MLawson 10
Record 3 CLawson 5

All on one sheet of Avery labels.

I know I need a loop with variables - I'm assuming on the OnPrint event of the label report, but this is totally stumping me and I'm now at screaming point. If anyone can point me in the right direction I would be most grateful.

There will be the eventual added complication of printing a batch of records off in one go, so an extra loop through, but one thing at a time.

VBA loop to check data

I have a field on a sub form that needs data to be in a specific format based on another fields information.
Example: Main Form(Field)1 needs SubForm(Field) data to be A#A#A#
Main Form(Field)2 needs SubForm(Field) data to be ######

Problem: I have the check the accuracy of the data part but what I am missing to how to check the multiple records that exist because the data is on a sub form which is a continuous form.

I thought I could just add a autonumber and create a loop using the first autonumber generated and the quantity of records.
---This would not work because the next autonumber in the table might be taken by another user for another record

Loop in access 2010 macro

I am trying to create a macro to loop through all the records in a form and replace a number field until it hits a record with a specific entry.
I am unable to find the command in the macro drop-down box. The command I am looking for is Do Until.
I would prefer to work through macros rather than in VBA as I don't know how to program using VBA

Loop Problem: looping all records

I have a form "frmTest" & subform "subfrmTestDetail". The subform "subfrmTestDetail" displays the recordset. I have a cmd button on "frmTest" with the following code.....
The idea is for the code to loop all records displayed in subform & update. It only updates the very first record & does not loop the entire recordset. Can anyone see where i've gone wrong & why it isn't looping all records?

Loop: Each subform in Form

All i need is the following pseudo code translated into actual working VBA code. For each value in a public array(1), I am attempting to loop through all fields(3) within all the subforms(2) on one particular form. If there is a match, the field is visible, if not, the field is hidden (I am using datasheet view)...