How to get value from form in Navigation form (1 Viewer)

Sokkheng

Member
Local time
Today, 14:17
Joined
Jul 12, 2023
Messages
34
I have one text box (text box in main form) that will get value from field in sub form after i double click that filed, it's work properly, but after i create Navigation Form (Navigation button) that attach to that form that text box can't get the value from the field in the sub form.
this is my formula : text box = Forms ! [main form] ! [sub form] ! [field]
please guide me how to correct it for work with Navigation form.
Thanks
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:17
Joined
Oct 29, 2018
Messages
21,473
Just make sure you are using the correct names for your controls.
 

Sokkheng

Member
Local time
Today, 14:17
Joined
Jul 12, 2023
Messages
34
Just make sure you are using the correct names for your controls.
here is my text box control
texbox = Forms![NavigationSubform]![frmStation]![supfrmProvinceStation]![StationId]
If i use direct in my form without in navigation form it's ok
texbox = Forms![frmStation]![supfrmProvinceStation]![StationId]
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:17
Joined
Sep 12, 2006
Messages
15,656
If you are on the main form, and the subform is a subform of the main form, then you should be able to use the control name reference, as the controls source.

= Subdetails!field name

Alternatively you can use the subform to change the value in the main form.

Me.parent!displayfield = whatever

This is aircode and the syntax may be off, but it's easier in general than trying to get a fully referenced form and field name.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:17
Joined
Feb 19, 2002
Messages
43,275
On a navigation form, only the VISIBLE subform can be referenced. You cannot reference a subform that is not loaded. So, from the mainform you can reference the ONE visible subform but no other. From any subform, you cannot reference any other subform because none is loaded.
 

Sokkheng

Member
Local time
Today, 14:17
Joined
Jul 12, 2023
Messages
34
Thanks for reply, now i still can't get value from that field. here are working properly if i use direct in (frmStation) that form

Private Sub StationID_DblClick(Cancel As Integer)
Dim VarStationCode As String
VarStationCode = Forms![frmStation]![supfrmqryProvinceStation]![StationID]
Forms![frmStation]![txtStationIdTemp] = VarStationCode
Forms![frmStation]!cmdFind.SetFocus
End Sub

But after i attach that frmStation to Navigation Subform i can't get the value from StationID field.
Please correct syntax for me when attach to Navigation Subform

Note. My flow mean when i double click on StationID field in subform (supfrmqryProvinceStation) it will pass the StationID value to txtStationIdTemp in main form (frmStation) and i will search the station detail by that StationID value.

Thanks
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:17
Joined
Oct 29, 2018
Messages
21,473
Are you able to post a sample copy of your db with test data?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:17
Joined
Feb 19, 2002
Messages
43,275
Note. My flow mean when i double click on StationID field in subform (supfrmqryProvinceStation) it will pass the StationID value to txtStationIdTemp in main form (frmStation) and i will search the station detail by that StationID value.
Use a popup form for this.
 

LarryE

Active member
Local time
Today, 00:17
Joined
Aug 18, 2021
Messages
591
But after i attach that frmStation to Navigation Subform i can't get the value from StationID field.
Please correct syntax for me when attach to Navigation Subform
You need to reference your Navigation SubForm Name when you define VarStationCode:
VarStationCode = Forms![Navigation Subform Name]![frmStation]![supfrmqryProvinceStation]![StationID]
 

Users who are viewing this thread

Top Bottom