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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One Calendar for Several Forms? 4

Status
Not open for further replies.

dRahme

Technical User
Jun 24, 2004
286
US
Hi, management has fallen in love with pop-up calendars for the various forms that require a date entry.

After making 5 of these, with the prospect of making many more, it occured to me that there may be a method for using the same calendar for several forms.

The calendar would need to recognize the form that opened it in order to populate the appropriate text box I think, and I do not know how to do that.

Any suggestions?

Thanks, dRahme
 
You could use OpenArgs to tell the calendar which form and field to write back to.
 
Hi, the way I understand openargs and my understanding is limited, with openargs you are passing a value from the main form to the form you are opening. If that is the case, what value do you pass to the calendar so the calendar can determine which form opened it?

Thanks, dRahme
 
I'm not at a computer that's loaded with Access, so I can't test this, but you might try something like:

If Me.Name = "YourFirstFormName" Then
'Place your code here for field to populate on 1st form
Else If Me.Name = "YourSecondFormName" Then
'Place your code here for field to populate on 2nd form
End If

and so forth. Not sure this will work, but believe it will. You could also use the Case structure in a similar way.

Hope this helps!

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
Or you could try:
Opening form:
Openargs: Me.Name & "," & Me.txtSomeControl.Name

Calendar:
astrArgs = Split(OpenArgs, ",")
frm = astrArgs(0)
fld = astrArgs(1)
Forms(frm).Controls(fld) = ...
 
How are ya dRahme . . .

In parallel with [blue]Remou[/blue], in the calling forms:
Code:
[blue]   DoCmd.OpenForm "CalendarFormName", , , , , , "[purple][b]FormName[/b][/purple],[purple][b]ControlName[/b][/purple]"[/blue]
Then in the [blue]AfterUpdate[/blue] event of the calendar control:
Code:
[blue]   Dim Ary
   
   [green]'Set date only if openargs has value.[/green]
   If Trim(Me.OpenArgs & "") <> "" Then
      Ary = Split(Me.OpenArgs, "'")
      Forms(Ary(0))(Ary(1)) = Me![purple][b]CalendarControlName[/b][/purple]
   End If[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks folks for all your help. I added all suggestions to my libray and resolved my dilemma.

Thanks again,

dRahme
 
I have a sample db (Pop-Up Calendar) do the same & recognizes which textbox called the calendar.

________________________________________________________
Zameer Abdulla
Help to find Missing people
Do not cut down the tree that gives you shade.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top