Solved Calendar (1 Viewer)

ClaraBarton

Registered User.
Local time
Today, 01:32
Joined
Oct 14, 2019
Messages
463
I'm using the PeterHibbs with Majp Calendar in my Cookbook for menu planning. I'd like to Add a Recipe on click to the appointment form. The onclick calls the main calendar and then the appointment and then fills in the recipe and the ID. So OpenArgs needs to go thru 2 forms.
Is this the right way? From the Recipe:
Code:
DoCmd.OpenForm "frmCalendarMain", _
        View:=acNormal, _
        DataMode:=acFormAdd, _
        OpenArgs:="me.recipe|" & Me.recipeid
From the open event of the main calendar:
Code:
DoCmd.OpenForm "frmCalendarAppt", _
        View:=acNormal, _
        DataMode:=acFormAdd, _
        WindowMode:=acDialog, _
        OpenArgs:=OpenArgs
And finally on the load event of the Appointment form:
Code:
Private Sub Form_Load()
  Dim intPos As Integer
  Dim strValue1 As String
  Dim strValue2 As String

  If Len(Me.OpenArgs) > 0 Then
    intPos = InStr(Me.OpenArgs, "|")

    If intPos > 0 Then     '10
      strValue1 = Left$(Me.OpenArgs, intPos - 1)     '  "me.recipe"
      strValue2 = Mid$(Me.OpenArgs, intPos + 1)        '  "1328"
     End If
  End If
Me.txtRecipe = strValue1
Me.RecipeNo = strValue2
End Sub
It doesn't work but I'll keep plugging if I'm on the right track.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:32
Joined
Feb 19, 2002
Messages
43,275
In the middle form, you need to reference its openargs property to pass along what it got in.

Use Me.OpenArgs so you don't confuse yourself.
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:32
Joined
Sep 21, 2011
Messages
14,301
You are passing in a literal word "me.recipe|"?
 

ClaraBarton

Registered User.
Local time
Today, 01:32
Joined
Oct 14, 2019
Messages
463
Pat Hartman: OpenArgs = Me.OpenArgs?
Gasman: No... I want the name of the recipe. What is wrong?
CJ_London... AH! Thank you!
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:32
Joined
Sep 21, 2011
Messages
14,301
You enclosed the control name within double quotes. That makes it a literal string.
You should walk your code and see if you have what you think you have.
 

ClaraBarton

Registered User.
Local time
Today, 01:32
Joined
Oct 14, 2019
Messages
463
Oh I do, I do. just checking my plan... the appointment form can also be called from the calendar and so different openargs. How do you check which form is opening it?
Code:
OpenArgs:=Me.Recipe & "|" & Me.recipeid
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:32
Joined
Sep 21, 2011
Messages
14,301
Oh I do, I do. just checking my plan... the appointment form can also be called from the calendar and so different openargs. How do you check which form is opening it? OpenArgs:=Me.Recipe & "|" & Me.recipeid
Pass in the form name as well?
I would also use the Split() function if that is the case.
 

tvanstiphout

Active member
Local time
Today, 01:32
Joined
Jan 22, 2016
Messages
222
Oh I do, I do. just checking my plan... the appointment form can also be called from the calendar and so different openargs. How do you check which form is opening it?
Code:
OpenArgs:=Me.Recipe & "|" & Me.recipeid
If you take me up on my suggestion to use the functions from the Northwind template, you would write:
OpenArgs:=StringFormat("RecipeID={0}&FormName={1}", Me.Recipe, Me.Name)
 

ClaraBarton

Registered User.
Local time
Today, 01:32
Joined
Oct 14, 2019
Messages
463
I got it, checked it out and use it so:
Code:
           If Nz(Me.OpenArgs, "") > "" Then
30            arArgs = Split(Me.OpenArgs, "|")
40            Me.txtRecipe = arArgs(0)
50            Me.RecipeNo = arArgs(1)
80        End If
Yours looks neater!
Thank you, Tom.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:32
Joined
Feb 19, 2002
Messages
43,275
OpenArgs = Me.OpenArgs?
You are talking the open args of the middle form and passing along the value in the OpenArgs parameter of the OpenForm method to the third form.

You were using named arguments in your example so:

OpenArgs: = Me.OpenArgs does that.

However, it is not clear why you are concatenating a literal value when you pass the RecipeID from the first form to the second.
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:32
Joined
Sep 21, 2011
Messages
14,301
You are talking the open args of the middle form and passing along the value in the OpenArgs parameter of the OpenForm method to the third form.

You were using named arguments in your example so:

OpenArgs: = Me.OpenArgs does that.

However, it is not clear why you are concatenating a literal value when you pass the RecipeID from the first form to the second.
I think that was an error Pat.
 

Users who are viewing this thread

Top Bottom