subform record loop in VBA
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.
Thank you for taking the time to report an issue.
What's wrong... Please write below.
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.
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.
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?
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.
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
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
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?