Copy value into another form

Heidestrand

Registered User.
Local time
Today, 09:20
Joined
Apr 21, 2015
Messages
73
Hello,

I have a small problem that I can't solve and I'd ask you for your help. My problem is that I want to copy the value of a text-field of form frmSnippet into another text field of form frmChange. But this is not possible, Access tells me that it can't find the form frmChange. But it's there, I checked the name.
22472379pd.jpg

My code looks like this:
Code:
     Const cstrForm As String = "frmChange"
     Dim strNr As String
     If CurrentProject.AllForms(cstrForm).IsLoaded Then
        DoCmd.Close acForm, cstrForm
     End If
        DoCmd.OpenForm cstrForm, WindowMode:=acDialog
        
     txtSAPNr.SetFocus
     Forms!frmChange![txtSAPNr] = Me![txtSAPNr]

Any idea why I get the runtime error 2450?
 
When you use acDialog, no code after that line runs until the form opened in that line is either closed or hidden. In other words, the code to set a value isn't running until the form is closed.
 
Thank you for your answer. After deleting WindowMode:=acDialog it copies the value.
But how can I open this form in something like a popup window (like on my picture)? I need a window mode and not the full screen.. Can I set the borders somehow?
 
Try this:

Display your Change form as a subform inside a popup main form. The subformcontrol and popup main form can be configured to look like an ordinary form by turning off the subformcontrol border and the selectors etc on the main form.

Enter the full reference (via the Forms Collection) to the textbox on the calling form as the MasterLinkFields property of the subformcontrol on the popup form. The ChildLinkFields is set as usual to the key field on the subform SourceObject.
 
Thank you for your answer. After deleting WindowMode:=acDialog it copies the value.
But how can I open this form in something like a popup window (like on my picture)? I need a window mode and not the full screen.. Can I set the borders somehow?

Another option is to go back to acDialog, but add the value you want to pass to the OpenArgs argument, and use the second form's open event to place it.
 
So I found my own way to display my form as a popup.
First you need to go into layout mode, adjust some settings for the form (like popup = yes, bound = yes, border type = changeable, cutting line = no, scrollbar = now, and some personal adjustmensts). No it looks like this:
22522017wd.png

Thanks all of you for your help :)
 

Users who are viewing this thread

Back
Top Bottom