Calendar - unable to locate the form where the date value will res

G

Guest

I create a module as below:

Option Compare Database

Option Explicit

Public frmName As String
Public CtrlName As String

and then, I code in the form below where the date value from the calendar
will reside:

Private Sub Image124_Click()

frmName = Me.Name
CtrlName = "combo58"
DoCmd.OpenForm ("calendar")
End Sub

The form mentioned above is inside other forms and tabs. When I run the
code, it cannot locate the form aforesaid. Do I need to make changes on the
frmName = me.name? It seems the application does not know the path to locate
the form.

The code in the save button in the calendar form is as below:

Private Sub Command1_Click()
Dim fomandcontrol As Variant

Forms(frmName).Controls(CtrlName) = Me.Calendar0.Value

'Forms![switch form]![new articles]![ForFrm]!Combo58.Value =
Me.Calendar0.Value
DoCmd.Close acForm, "calendar"
End Sub

I will appreciate anyone who will solve my problem.
 
G

Guest

Public frmName As String
Public CtrlName As String

You have to make this global

Global gfrmName as string
Global gctrlName as string

Or you should refer to the object where these variables are declared.
E.g. the name of form object opened would be Test
then you should refer them as Forms("Test").frmName and Forms("Test").CtrlName

So Globals will work Fine

another trick is to Define a Global Variable as Object

e.g.
global gControl as Object
or even
Global gControl as Control

and then you assign the Control to be used to this variable
by using

set gControl = Me.Name.Combo58
DoCmd.OpenForm "Calendar"

Private Sub Command1_Click()
gControl= Me.Calendar0.Value
End Sub


- Raoul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top