I apologize for cross posting, but I did not get any responses in VB 5&6.
I want to be able to open a form as a subform sourceobject based on a string that is built from two other strings. The first is a name convention of a group of forms ("frm_Ques_"), and the second is a number between 1-73, which represents the number of a given form. When it is combined, the string should look something like "frm_Ques_34", and then frm_Ques_34 would be opened as the sourceobject for the given main form.
Here is what the code I built looks like (but it does not work).
The goal of this code is have a 'pick up where you left off' option in an assessment db. I thought it would be a rather straightforward option. Now, I'm not so sure. I do not want to have to develop a 'case scenario' for all 73 subforms. But I cannot get Access to access the string as a form name. StrongM has solved this to some degree, but I cannot get his code to work with mine.
StrongM has answered many posts with code for a similar issue, but I cannot get his code to work.
Any ideas appreciated!
I want to be able to open a form as a subform sourceobject based on a string that is built from two other strings. The first is a name convention of a group of forms ("frm_Ques_"), and the second is a number between 1-73, which represents the number of a given form. When it is combined, the string should look something like "frm_Ques_34", and then frm_Ques_34 would be opened as the sourceobject for the given main form.
Here is what the code I built looks like (but it does not work).
Code:
Private Sub cmdPickUp_Click()
Dim frm As Form
Dim frm2 As String
Dim strEnumerator As String
Dim strSubObject As String
Set frm = Forms(frmPCP_Edit_Main)
strEnumerator = Me.StatusID
strSubObject = "frm_Ques_" + strEnumerator
Set frm2 = Forms(strSubObject)
If Me.StatusID < 1 Then
frm.frm_Sub_Object.SourceObject = "frm_Ques_01"
Else
frm.frm_Sub_Object.SourceObject = frm2
End If
End Sub
StrongM has answered many posts with code for a similar issue, but I cannot get his code to work.
Any ideas appreciated!