Solved Calendar

ClaraBarton

Registered User.
Local time
Today, 07:28
Joined
Oct 14, 2019
Messages
661
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.
 
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.
 
You are passing in a literal word "me.recipe|"?
 
Pat Hartman: OpenArgs = Me.OpenArgs?
Gasman: No... I want the name of the recipe. What is wrong?
CJ_London... AH! Thank you!
 
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.
 
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
 
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.
 
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)
 
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.
 
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.
 
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

Back
Top Bottom