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

concatenated string as variable form name

Status
Not open for further replies.

LowBrow

Technical User
Jun 1, 2001
100
US
StrongM has listed answered similar questions to mine many times (as here: thread222-795815), but I cannot get his solution to work for what I want. Here is some of code (it doesn't work, but it may help explain what I am trying to accomplish):
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

StatusID refers to the primary key of an edit table that will be a number between 1-73. These become the enumerator of the naming convention for my subforms. As users click through the subforms, the respective enumerator for that subform is updated to a hidden text box, which is in turn tied to the master record primary key field.

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.

frmPCP_Edit_Main is the main form for the assessment.
frm_Sub_Object is the name of the subform control on frmPCP_Edit_Main.

All ideas appreciated! Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top