Linking a missing subform A2K7

PC User

Registered User.
Local time
Today, 02:21
Joined
Jul 28, 2002
Messages
193
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.BusinessID = gintBusinessID
End Sub
I've searched through this forum and I haven't found anything on this technique.

Thanks,
PC
 
Last edited:
Try hiding the SubForm instead or Placing the value you want to keep within the Tag of the Main Form or OpenArgs property of the Form you are to open. Convert to the required Data Type when retrieving the Value.

.
 
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.
This sounds like the behavior of Lookup fields at table level -

See here for more about that:
Lookup Fields In Tables
 

Users who are viewing this thread

Back
Top Bottom