Referencing all records in a subform

Sym

Registered User.
Local time
Today, 11:47
Joined
Feb 21, 2015
Messages
40
I am trying to add a save/close button to a form that will only close if certain conditions are met and if they arnt then display a message box.

I got the basics on how to save and close the form, do a simple if statement and display the message I want but the problem im running into is my subform can have multiple records and of those records each records status is set by 3 different checkboxes. I need all of those records status to be same when the form is closed.

if I do an if statement like

If Me!frmDataform1subform.Form!StatusID.Value = 1 then
docmd....

then all it looks at is the first record, how do I get my if statement to look at all the records in the subform?
 
your form has a recordset which you can parse, but what normally happens is the record is saved when you click on the next record so you are closing the stable door after the horse has bolted.

If you don't want to save any of the records until all are checked correctly then you will need to investigate using adodb disconnected recordsets (google it to find out more)

However if

I need all of those records status to be same when the form is closed.

can be translated to

I need the current record to have the same status as the previous record

then in the form before update event you can store the relevant values of that record in form public variables to compare with the next record
 
If you don't want to save any of the records until all are checked correctly then you will need to investigate using adodb disconnected recordsets (google it to find out more)

Using a disconnected recordset for this task is very complex especially when done properly. Transacted Bound Forms do the job right and are relatively simple.

http://www.access-programmers.co.uk/forums/showthread.php?p=1332329

A crude example database is attached.
 

Attachments

Users who are viewing this thread

Back
Top Bottom