LjushaMisha
Registered User.
- Local time
- Today, 12:31
- Joined
- Mar 10, 2017
- Messages
- 77
I have a continuous form named "frmRezultati" (i.e. frmResults) with one of the controls named "SesId". DblClick of this control
opens INSTANCE of "frmRezultati". Idea is to change recordset of new "instance" form, dependig on value in the control which was doubleclicked.
I don't have a problem with declaring recodset and so on.
My problem is REFERENCING controls in form's "frmRezultati" instance.
What have I done so far:
a. In standalone module I have declared NEW COLLECTION "named" KLONI (i.e. Clones) ---> Dim Kloni As New Collection
b. I made a function for "opening" instances (With great help of Mr. Brown instructions (Code on the end of thread)
Opening instances with needed Captions works great. I'm able to openup to 99 instances with "no effort at all". But I don't need them so many.
c. I made function "ShraniSesId" to check value in doubleclicked control SesID of form's instance
ShraniSesId = Screen.ActiveForm!SesId
Almost everithing work's well. Only last two lines (Debug.Prints) "give me wrong answer" - as commented in code
HERE IS THE CODE:
Function Klon_frmRezultat_Funkcija_01()
Dim frm As Form
Dim obj As Object
Dim i As Integer
Dim j As Integer
' Function
ShraniSesId
Debug.Print "1. " & Format(ShraniSesId, "000000") 'Result: 1. 000025, correct
' Open NEW instance, make it visible and give it .Caption
Set frm = New Form_frmRezultati
Set obj = Screen.ActiveForm
i = Right(Screen.ActiveForm.Caption, 2) + 1
frm.Visible = True
frm.Caption = "LEVEL " & i & ""
' Append it to collection Kloni.
Kloni.Add Item:=frm, Key:=CStr(frm.Hwnd)
Debug.Print "2. Instance's index: " & i 'Result: 2. 3, correct
Debug.Print "3. Instance's Caption: " & Kloni(i).Caption 'Result: 3. LEVEL 3, correct
Debug.Print "4. Value !SesID from Funtion : " & ShraniSesId 'Result: 4. 1, WRONG - STRANGE WHY 2nd call RESULT IS WRONG
Debug.Print "5. Value !SesID from Sub: " & Kloni(i)!SesId 'Result: 5. 1, WRONG
'In fact 1 is first value of SesId on "original" form
'In this dblclick I need result 000025 to continue (as firs result of the function
Set frm = Nothing
End Function
Thanks in advance for all helpfull suggestions. I think/know I could make it with Screen.ActiveForm!SesID. But I would have problems in
future for example SET new recordset for which form or better which instance of a form???, requery which instance, and so on and so on.
opens INSTANCE of "frmRezultati". Idea is to change recordset of new "instance" form, dependig on value in the control which was doubleclicked.
I don't have a problem with declaring recodset and so on.
My problem is REFERENCING controls in form's "frmRezultati" instance.
What have I done so far:
a. In standalone module I have declared NEW COLLECTION "named" KLONI (i.e. Clones) ---> Dim Kloni As New Collection
b. I made a function for "opening" instances (With great help of Mr. Brown instructions (Code on the end of thread)
Opening instances with needed Captions works great. I'm able to openup to 99 instances with "no effort at all". But I don't need them so many.
c. I made function "ShraniSesId" to check value in doubleclicked control SesID of form's instance
ShraniSesId = Screen.ActiveForm!SesId
Almost everithing work's well. Only last two lines (Debug.Prints) "give me wrong answer" - as commented in code
HERE IS THE CODE:
Function Klon_frmRezultat_Funkcija_01()
Dim frm As Form
Dim obj As Object
Dim i As Integer
Dim j As Integer
' Function
ShraniSesId
Debug.Print "1. " & Format(ShraniSesId, "000000") 'Result: 1. 000025, correct
' Open NEW instance, make it visible and give it .Caption
Set frm = New Form_frmRezultati
Set obj = Screen.ActiveForm
i = Right(Screen.ActiveForm.Caption, 2) + 1
frm.Visible = True
frm.Caption = "LEVEL " & i & ""
' Append it to collection Kloni.
Kloni.Add Item:=frm, Key:=CStr(frm.Hwnd)
Debug.Print "2. Instance's index: " & i 'Result: 2. 3, correct
Debug.Print "3. Instance's Caption: " & Kloni(i).Caption 'Result: 3. LEVEL 3, correct
Debug.Print "4. Value !SesID from Funtion : " & ShraniSesId 'Result: 4. 1, WRONG - STRANGE WHY 2nd call RESULT IS WRONG
Debug.Print "5. Value !SesID from Sub: " & Kloni(i)!SesId 'Result: 5. 1, WRONG
'In fact 1 is first value of SesId on "original" form
'In this dblclick I need result 000025 to continue (as firs result of the function
Set frm = Nothing
End Function
Thanks in advance for all helpfull suggestions. I think/know I could make it with Screen.ActiveForm!SesID. But I would have problems in
future for example SET new recordset for which form or better which instance of a form???, requery which instance, and so on and so on.