Grouping Textboxes on Forms/Subforms

Soton

Registered User.
Local time
Today, 12:24
Joined
Mar 17, 2008
Messages
17
I have a main form, which is bound to table MainTable, and a sub form, bound to table SubTable, with a one-to-many relationship. The records in MainTable can be one of two types and there is field ‘Type’ to hold the type. Each type has its own sequential number held in fields ‘One’ and Two’ – if there is a number in field ‘One’, field ‘Two’ holds ‘-‘, and vice versa. The ‘seed’ for the sequential numbers are held in a table with one record and two fields – one field holding the last number for type ‘One’ and the other holding the last number for type ‘Two’.

A reference number is created and displayed on the main form in a text box. The reference is made up from the contents of two text boxes (actually, they are Combo boxes) on the Main Form, two text boxes on the SubForm, and the relevant sequential number. So, if the main form boxes were A and B, and the subForm boxes were C and D, the reference would be ‘Aa/Bb/Cc/Dd/XX’ where Aa represents the value in box A, etc, and XX represents the current value of the sequential number for the particular record type. The second record type could be based on a different set of boxes, say ‘Ee/Ff/Gg/Hh/YY’, with a similar split between main form and subform, but once I know how to do it for one set, I’m hoping I can adapt it for the second set.

I have written the code to extract the relevant sequential number, increment it ready for next time, create the reference string and display it in a text box. I could ‘trigger’ the creation and display of this reference from a button on the form but what I would like to do is have it created automatically after all four boxes (A, B, C and D) have been filled. I could put a trigger on each box and build up the reference a section at a time but that seems to be rough and ready and I would prefer a more elegant solution. Is there a way of managing the input to the four boxes, bearing in mind that two are on the main form and two are on the sub form, to trigger the procedure to create the reference when, and only when, all four boxes have been ‘filled’.

A second problem I have, which in some ways is an extension of the first, is how to ensure that all the mandatory fields on the mainform/subform have been completed before moving to another record or creating a new record. Note that only a selection of the fields on the forms have to be completed, its not every field.
 
That's a lot of text. You have to get to the point more quickly or use a sample database to illustrate the problem.
 
OK Guus2005. I thought giving a full explanation would help set the scene.

Put simply, I have say three text boxes. Data is entered into these boxes and the values are concatenated and the resulting string is displayed in another text box. How do I force the user to enter data in all three text boxes and not just one or two.
 
You can use the "On lost focus" event to check when the form losses focus (i.e. user thinks he is done with that form)
Then have some coding there to make sure all the needed boxes are filled in...

Or use the "On Exit" event of the "subform window"

Good luck !
 
I thought of using the Dirty 'trigger' with code to then check each box I am interested in has an entry and possible colour the background of the ones which were still empty. It doesn't seem very elegant but hopefully it should work. Am I using the correct events trigger. The 'on lost focus' when closing the form is too late as I want to process the results into another text box.
 
On Dirty only gets triggered when the form goes from "clean" to Dirty. I.e. at the first changed character/textbox.

Using the On Exit event or On Close or something like that you can Cancel the closing of the form, forcing the user to stay in the form untill such time as your requirements are met.
 

Users who are viewing this thread

Back
Top Bottom