Form Field populates before after code executes

spinktec

Registered User.
Local time
Today, 01:40
Joined
Nov 30, 2007
Messages
20
I've succeded in populating the field of a form using code from another form; however, it seems that the field is populated too late to use the data. I have no problem getting the information into the field; the problem is that all events occur before the field is filled which means I can't act on the data upon opening, loading, current... etc.

Any suggestions on how I could get the code to begin after the field is populated instead of before.
 
Can you explain a little more, with actual details, of what you are trying to accomplish? It may be something we can suggest an alternate method for which will then potentially solve your problem. But as it stands now, there's not much to go on.
 
maybe you need to learn how to use modal forms, or open forms in modal mode, to halt execution of code until that form closes.

search help on the docmd.openform method and look at the acDialog argument.

If I had some code like

...do A
....do B
docmd.openform "popupform1", acNormal, , ,acFormEdit,acDialog
...do c
...do d
etc

actions A and B will occur, then a popup form will open in modal mode. This means that the rest of the code (actions C and D) will not run until after that form is closed again.

if I did not specify the acDialog argument, all the code would excute without pause.
 
This is the code I am using in the form "GraphicRequest" to open a form "SelectChildren" that will, upon opening, populate a field (in fact the only field) on a form. After that field is populated I want to run code to generate captions for and activate certain buttons. The idea is to use the form "SelectChildren" not only with the form "GraphicRequest" but with any form that can populate and open "Select Children"; that's why I chose not to look back from "SelectChildren" into the field "ControlNum" in "GraphicRequest".

Private Sub ButtonChildren_Click()

Dim RefHolder As String

RefHolder = Me.FieldControlNum.Value

DoCmd.OpenForm "SelectChildren", acNormal

Forms!SelectChildren.FieldReferenceNum = RefHolder

DoCmd.Close acForm, "GraphicRequest" , acSaveNo

End Sub
 
Have you tried declaring refHolder as Public in a standard module so that the scope is beyond the form you are on?

For that matter, have you tried just

Forms!SelectChildren.FieldReferenceNum = Me.FieldControlNum

to see what happens?
 
I am able to get the data into the field by using:

Forms!SelectChildren.FieldReferenceNum = Me.FieldControlNum

However, it doesn't change the issue that the data in the field arrives after all the form events occur; therfore, I can't act on the data. I put a useless button labeled "See other buttons" and let the click event of that button begin the code; that worked fine, but I really don't want to do something so clumbsy as that. I just want the code to run after the field has been populated.
 
Is there a reason why you have to have the code in the Select Children form? Can you make a function or sub in a standard module that you can call from whatever form and it will open the select children form and do all of the code that the form would do, but with the added advantage that you can do it in the sequence you want.
 
I think that's what I'll do. Since I want to use the Select Children form to find the children of many different forms I'll just use a public module and call that module whenever I need. That'll actually be a little more elegant anyway.

Thanks
 

Users who are viewing this thread

Back
Top Bottom