Can we change linking with the subform through code? How?
Can we change linking with the subform through code? How?
Don't know what that means. Linking to what?
You mean changes its record source? Change its parent/child linked fields? Change the subform control source object? In any of those cases, yes.
If something else, then I don't know.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
Yes . From the main form
Code:Me.YourSubFormContainer.LinkMasterFields="BlahBlah" Me.YourSubFormContainer.LinkChildFields="Filbble"
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓
The following code :
Me.CASH_OFFICE_subform.LinkMasterFields = FNAME
Me.CASH_OFFICE_subform.LinkChildFields = FNAME
asks for the variable FNAME.
Both Master and Child fields have the same name (FNAME).
you left off the quotes per example
FNAME isn't a variable - or at least if it is, it won't work. FNAME is a field name but without quotes it's probably being interpreted as an object when it expects a string value.
Either enclose in quotes or maybe brackets: "FNAME" or [FNAME]
you left off the quotes per example
FNAME isn't a variable - or at least if it is, it won't work. FNAME is a field name but without quotes it's probably being interpreted as an object when it expects a string value.
Either enclose in quotes or maybe brackets: "FNAME" or [FNAME]
Your advice is working. But another problem has arisen. I had coded my subform so that if I double click on any field on the subform the corresponding name & address will be transferred to the main form. Now this is working only when linking is on LNAME. When linking is on FNAME it doesn't work. Please guide me as to what I should do. I have attached a db to demonstrate it.
try putting me.refresh at the end of MoveToMain()
I'm not getting what you're trying to do or why you're doing it. The data for the subform and main form is in the same table. Cannot see why you need a subform at all. They are meant for situations where you have one record (tblOrders.OrderNumber) related to many records (tblOrderItems.OrderNumber) - not when names and addresses exist in the same record in one table. You probably should check out some tutorials on subforms.
try putting me.refresh at the end of MoveToMain()
I'm not getting what you're trying to do or why you're doing it. The data for the subform and main form is in the same table. Cannot see why you need a subform at all. They are meant for situations where you have one record (tblOrders.OrderNumber) related to many records (tblOrderItems.OrderNumber) - not when names and addresses exist in the same record in one table. You probably should check out some tutorials on subforms.
The CR NO is the receipt no. If the same person comes again instead of typing his details they can be got from the record. This is the purpose of the subform. Now, when in a new record we type the LNAME it shows the corresponding records in the subform and when we doble click on the field in the subform it tranfers the corresponding details to the main form. But the problem is that when in a new record we type FNAME it shows corresponding details in the subform but when we double click on the field of the subform it does not transfer the details to the main form.
Still no subform required for what you describe. Other methods would be
e.g. have unbound combo or listbox on main form. When on new record, select the CR or whatever. Details get populated.