Open form with tab control to specific primary key? (1 Viewer)

kawai6rr

Registered User.
Local time
Today, 07:41
Joined
Aug 26, 2009
Messages
21
I have a datagrid/list box that populates a few row/columns, one of which is a primary key “FacilityID”. When double clicking the a specific row a new form will open with that FacilityID assigned to it. This worked fine until I put a tab control on realizing I needed more. How do you reference and tab control on the new form with the FacilityID from the datagrid?

This doesn't work: stDocName = "Check_List!TabCtl25"


Dim rs As DAO.Recordset
Dim strsql As String
Dim strFacilityID As String

strFacilityID = Me.lst_CheckListView.Column(0)
strsql = "SELECT FacilityID FROM CheckList WHERE FacilityID = " & strFacilityID

Set rs = CurrentDb.OpenRecordset(strsql)

'Check to see if the recordset actually contains rows
If Not (rs.EOF And rs.BOF) Then
stDocName = "Check_List!TabCtl25"
stLinkCriteria = "[FacilityID]=" & strFacilityID
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "No Match"
Call ChecklistEnter
End If

rs.Close 'Close the recordset
Set rs = Nothing 'Clean up
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:41
Joined
Oct 29, 2018
Messages
21,449
Hi. Tab Controls shouldn't matter; unless, you're actually talking about using a subform too. Are you?
 

June7

AWF VIP
Local time
Today, 06:41
Joined
Mar 9, 2014
Messages
5,463
A Tab control is irrelevant when referencing controls on form. If you are actually using a Navigation Form that is different issue.

What do you mean by 'datagrid' - a form in Datasheet View?
 

Doubleecpu

New member
Local time
Today, 07:41
Joined
Apr 23, 2020
Messages
2
1. On the form (or report) with tab control you need to have a control that has the value of strFacilityID (i.e Text_FacilityID)
2. Then you need to Link master Fields = Text_FacilityID and Link Child Fields = TableName.FacilityID to the SubForm/Report on each tab.
3. On the Subform/Report you will need to have the controlSource TableName.FacilityID as part of the Record Source data.

A more advanced way to do the same thing would be to update the Record Source for each SubForm/Report before opening the Form. You would need to do it this way if you operate on a slow network or have a lot of data.
 

kawai6rr

Registered User.
Local time
Today, 07:41
Joined
Aug 26, 2009
Messages
21
This is a little embarrassing but for some reason the primary tables connection was lost once I reconnected it everything is working properly. Thanks for all the replies much appreciated.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:41
Joined
Oct 29, 2018
Messages
21,449
This is a little embarrassing but for some reason the primary tables connection was lost once I reconnected it everything is working properly. Thanks for all the replies much appreciated.
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Top Bottom