Link between switching subforms

P

PC User

I've adopted a programming style of switching between subforms,
instead of opening and closing forms. Although I've linked between a
main form and a popup form, now I need to link between opening and
closing subforms. I've tried to use a global variable to store my key
field's value (BusinessID), but Access 2007 acts strangely in that it
returns the string with the name of the business and not its ID
number. I've tried to prevent this by defining the global variable as
an integer (Public gintBusinessID As Integer), but it still returns a
string.

Basically, I need to switch from one subform which can have multiple
records related to it in another subform. The problem in switching
between subforms is that when the second subform appears the previous
subform is no longer there to reference and pick up the value of the
BusinessID. That is why I tried to use a global variable. Has anyone
used this technique and have an example of its use.

To switch between subforms, I use the following code:
Code:
Private Sub btnCESWpage_Click()
Forms("frmMAIN")!ctlGenericSubform.SourceObject =
"ffrelcolaExemptTreatment"
Forms("frmMAIN")!ctlGenericSubform.Form!BusinessID = gintBusinessID
End Sub

I've searched through this forum and I haven't found anything on this
technique.

Thanks,
PC
 
M

miss031

I have a design based on this format. I have the main value (contact_ID)
selected on the main form, and each subform that I choose picks up the value
from the main form. I use an option group to choose which subform to open.
Here is my code for the option group.


Private Sub frame_choose_sub_AfterUpdate()
On Error GoTo Err_frame_choose_sub_AfterUpdate

If frame_choose_sub = 1 Then
Forms![add_new_all].subf_main_blank.Visible = True
Forms![add_new_all].subf_main_blank.SourceObject =
"subf_main_contact_info"
Forms![add_new_all].subf_main_blank.LinkMasterFields = "contact_ID"
Forms![add_new_all].subf_main_blank.LinkChildFields = "contact_ID"
ElseIf frame_choose_sub = 2 Then
Forms![add_new_all].subf_main_blank.Visible = True
Forms![add_new_all].subf_main_blank.SourceObject = "subf_main_cashiering"
Forms![add_new_all].subf_main_blank.LinkMasterFields = "contact_ID"
Forms![add_new_all].subf_main_blank.LinkChildFields = "contact_ID"
ElseIf frame_choose_sub = 3 Then
Forms![add_new_all].subf_main_blank.Visible = True
Forms![add_new_all].subf_main_blank.SourceObject = "subf_main_payouts"
Forms![add_new_all].subf_main_blank.LinkMasterFields = "contact_ID"
Forms![add_new_all].subf_main_blank.LinkChildFields = "contact_ID"
End If

Exit_frame_choose_sub_AfterUpdate:
Exit Sub

Err_frame_choose_sub_AfterUpdate:
MsgBox Err.Description
Resume Exit_frame_choose_sub_AfterUpdate

End Sub
 
P

PC User

Interesting approach. Only certain subforms in my design will then
actually use the Master/Child Field link; so when I call those other
subforms I can clear the link using a blank string such as " ".
Otherwise, I'll get an error.

Thanks for the suggestion.

PC
 
M

miss031

It looks like you can just leave those 2 lines out. I tried commenting them
out in my code, and nothing bad happened.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top