VBA in Navigation form (1 Viewer)

setis

Registered User.
Local time
Yesterday, 22:18
Joined
Sep 30, 2017
Messages
127
I am trying to understand the navigation forms.

I have 2 forms [fromMemberDB] and [frmCases]

I have dragged and dropped these 2 forms into a Navigation form [frmMemberNav]and I can switch between the 2 with the tabs.
In [fromMemberDB] there is a field called "MemberID" and in [frmCases] there is one with the same Name "MemberID"

I need that the "MemberID" from [frmCases] equals the one from [fromMemberDB].

I need to place some VBA and the first question is where. In the NavigationSubform? Or is it in the actual texbox for the "MemberID" on the Navigation form?

I've tried different things with the code:
Me.MemberID=Forms![frmMemberNav]![NavigationSubform].[Form]![MemberID]

Would the right event to place it in be "Before Update"?


Can I get some help with this, please?
 

Minty

AWF VIP
Local time
Today, 06:18
Joined
Jul 26, 2013
Messages
10,366
Personally I avoid the inbuilt navigation forms as they are a right royal pain to work with. They appear to load each tab as a subform on load, meaning you can't refer to the unloaded form easily, as it doesn't actually exist on the navigation form at that point in time.

Create you own form with the tabs on it, and load each form as a subform on the tabs. You can then refer to them in the normal way.
 

setis

Registered User.
Local time
Yesterday, 22:18
Joined
Sep 30, 2017
Messages
127
Personally I avoid the inbuilt navigation forms as they are a right royal pain to work with. They appear to load each tab as a subform on load, meaning you can't refer to the unloaded form easily, as it doesn't actually exist on the navigation form at that point in time.

Create you own form with the tabs on it, and load each form as a subform on the tabs. You can then refer to them in the normal way.

Thanks!

When you say "Create you own form with the tabs on it", can I use the object Design>Navigation Control?

I still fail to refer to an object from tab to tab.

I have some members details with a MemberID in a tab and I need on a second tab to get the MemberID from the first one when I open it.. I can't really figure it out. :banghead:
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:18
Joined
May 7, 2009
Messages
19,231
on the Main Navigation Form, add an unbound
textbox (txtMemberID). Set its visible property
to no.

click on the "MemberTab" where formMemberDB belongs.
click on the upper left corner of the subform.
click it again making sure you see the black dot marker
is inside.
add code to the Current Event and Load Event of the subform:

Code:
Private Sub Form_Current()
Forms![navigation form]!txtMemberID = Me.MemberID
End Sub

Private Sub Form_Load()
If Trim(Forms![navigation form]!txtMemberID & "") <> "" Then
    Me.Recordset.FindFirst "[memberid]=" & Chr(34) & Forms![navigation form]!txtMemberID & Chr(34)
End If
End Sub

if memberid is numeric, remove the Chr(34) from the above code.

now click on the "Cases" tab of the navigation form.
select the "frmCases", by clicking the upper left corner
of the form. if not black marker is seen, click it again.

now add code to the Load Event of the:

(let say the recordsource of this subform is
"SELECT * From tblCases")

Code:
Private Const myRecordsource As String = "SELECT * From tblCases"
Private Sub Form_Load()
    If Trim(Forms![navigation form]!txtMemberID & "") <> "" Then
        Me.RecordSource = myRecordsource & " where [MemberID] = " & Chr(34) & Forms![navigation form]!txtMemberID & Chr(34)
    End If
End Sub

remove Chr(34) from the above if memberid is numeric.

that's it.
 

Users who are viewing this thread

Top Bottom