Problem with subform

Toine

New member
Local time
Today, 23:23
Joined
Sep 24, 2007
Messages
7
I have a form 'FrmVandaag' with a subform 'SubFrmBijzZoVandaag' If i click on a record in the subform, a new form (FrmZichtorders) is opened with non depended text boxes. The form Frmzichtorders can be opened from from different forms that's why I declared the variable 'formuliernaam as string'.

In the form 'Frmzichtorders'is the following code to fill the fields based on an ID from the calling form.

With Forms(formuliernaam)
Me.Artikel = .Artikel
Me.Op_zicht_van = .[Op zicht van]
Me.Op_zicht_tot = .[Op zicht tot]
Me.Firma = .Firma
etc.

This method works perfect when 'formuliernaam' is a form (eg. formuliernaam = "frmoverzicht zichtorders") but if the calling form is a subform (eg. formuliernaam = "Forms!frmvandaag!SubFrmBijzZoVandaag.Form"), I get an error that the form cannot be found. How should i refer to the subform correctly? formuliernaam = ....
 
When I use the following lines, it works perfectly

With Forms![frmvandaag]![subfrmbijzzovandaag].Form
Me.Artikel = .Artikel
Me.Op_zicht_van = .[Op zicht van]
Me.Op_zicht_tot = .[Op zicht tot]
etc.

but..
When I use this code, i get an error that the form cannot be found.

Dim formuliernaam As String
formuliernaam = "[frmvandaag]![subfrmbijzzovandaag].Form"
With Forms(formuliernaam)
Me.Artikel = .Artikel
Me.Op_zicht_van = .[Op zicht van]
Me.Op_zicht_tot = .[Op zicht tot]

What am I doing wrong???
 
try this
Code:
Dim formuliernaam As String
formuliernaam = Forms![frmvandaag]![subfrmbijzzovandaag].Form
With formuliernaam
Me.Artikel = .Artikel
Me.Op_zicht_van = .[Op zicht van]
Me.Op_zicht_tot = .[Op zicht tot]
 

Users who are viewing this thread

Back
Top Bottom