How to get value from form in Navigation form

Sokkheng

Member
Local time
Today, 19:07
Joined
Jul 12, 2023
Messages
40
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
 
Just make sure you are using the correct names for your controls.
 
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]
 
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.
 
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.
 
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
 
Are you able to post a sample copy of your db with test data?
 
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.
 
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

Back
Top Bottom