开发者

When loading a form, how do I retrieve the data passed by the "parent" form?

开发者 https://www.devze.com 2023-02-28 18:45 出处:网络
This is the line which passes the argument to the \"child\"开发者_开发百科 form: DoCmd.OpenForm \"Main\", acNormal, , , , acWindowNormal, tr.GetEmployeeName(uname)

This is the line which passes the argument to the "child"开发者_开发百科 form:

DoCmd.OpenForm "Main", acNormal, , , , acWindowNormal, tr.GetEmployeeName(uname)

Then this is the code for when the "child" form loads:

Private Sub Form_Load()

Dim i As String
i = CStr(Login.OpenArgs)
MsgBox i

End Sub

Thanks a lot!


The argument is already passed as a string, and is a property of the "child" form:

Private Sub Form_Load()  
    Dim i As String 
    i = Me.OpenArgs 
    MsgBox i  
End Sub 

EDIT: I almost missed this - it's been a while . . .

More editing: It looks like you are treating the OpenArgs as a property of the Parent form. I shall assume your Parent form is "login", and your child form is "Main", since you appear to be invoking a Form named "Main" in that line of code.

The openArgs is a property of the form now opening, passed to the child from the parent. Therefore, you reference the OpenArgs property as shown above.

Unless I am missing something, anyway . . .

0

精彩评论

暂无评论...
验证码 换一张
取 消