Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in code.....addressing form from subform

Status
Not open for further replies.

terre

Technical User
Feb 2, 2003
97
AU
The following code

Dim Pth As String
Dim frmName As String

frmName = "DLO1"
Pth = "C:\XXX"

Forms!frmName![Photos].Form!PathtoDoc = "#" & Pth & "#"

gives the error

Cant find Form frmName

What am I missing please?
 
More likely you want:

Forms!DLO1!PathtoDoc = "#" & Pth & "#"

If you want to reference forms with a variable, you can't use bang notation. Instead:

Forms(frmName).Controls("PathtoDoc") = "#" & Pth & "#"


 
Thank You Joe

Forms(frmName)![Photos].Form!PathtoDoc = "#" & Pth & "#"

Works fine

 
If you are working in the subform, you can also reference a control in the main form like this:

Me.Parent.PathtoDoc

Bob
 
Thanks BSman

The code is in a function.....and wont let me use Me.Parent

And frmName is a variable ... as is PathToDoc

But it works now....thanks muchly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top