working with currentRecord

fdelval

New member
Local time
Today, 11:50
Joined
Jan 25, 2010
Messages
8
Hello all!

I want to retrieve the fields of the selected value in a subform

I have a form with a subform inside in access 2003.

If i select a row in that subform, with this code:
[mySubform].Form.CurrentRecord i can get the number of the row, ie: 1 if is the first row.


Now, how can i retrieve a value of a field of that record??
 
Hello all!

I want to retrieve the fields of the selected value in a subform

I have a form with a subform inside in access 2003.

If i select a row in that subform, with this code:
[mySubform].Form.CurrentRecord i can get the number of the row, ie: 1 if is the first row.


Now, how can i retrieve a value of a field of that record??


Just call the name of the Field you would like to see the value of. For example if you want to view CustomerName you do this:

SubformName.Form![CustomerName]
 
Just call the name of the Field you would like to see the value of. For example if you want to view CustomerName you do this:

SubformName.Form![CustomerName]


but how can i retrieve only the value of the field "address", which belongs to the selected record in the subform??






i mean:

id - address - name
1 street paul
2 street betty
3 road idontknow

if i am currently selecting the second row, how can i get the name, which is betty?
 
Create a that will include all the address fields plus the customer's ID. Then create a subform and use that newcly created form as the Source Object of the subform. Link the ID's (i.e. CustomerID) of the subform and main form.
 
Create a that will include all the address fields plus the customer's ID. Then create a subform and use that newcly created form as the Source Object of the subform. Link the ID's (i.e. CustomerID) of the subform and main form.

uh oh, i dont understand sorry, please, explain further.

thanks in advance for your time.
 
Create a form that will include all the address fields plus the customer's ID. Then create a subform and use that newcly created form as the Source Object of the subform. Link the ID's (i.e. CustomerID) of the subform and main form.

On the first line I missed out, "Create a FORM".

So what you do is you create a form based on the Customers table, i.e. it should have the CustomerID, Address, Street etc.

Then go back to your main form, create a subform based on the Customer's form you created above. Use the CustomerID as the link between the main form and the subform. Was the clearer? I think one of the moderators on this forum have a diagram that explains how you can do this in Edit view.
 
On the first line I missed out, "Create a FORM".

So what you do is you create a form based on the Customers table, i.e. it should have the CustomerID, Address, Street etc.

Then go back to your main form, create a subform based on the Customer's form you created above. Use the CustomerID as the link between the main form and the subform. Was the clearer? I think one of the moderators on this forum have a diagram that explains how you can do this in Edit view.


Im gonna try that, but before start, i have a doub.

What is the code i should add in order to get the value of the field the user is selecting?
 
With the setup I described above you don't need code for it to show related records. It's a subform, it looks up its values from the parent form using the Customer. Search on 'how to create a subform in Access'. If you're still stuck, let me know.
 
Hello all!

I want to retrieve the fields of the selected value in a subform

I have a form with a subform inside in access 2003.

If i select a row in that subform, with this code:
[mySubform].Form.CurrentRecord i can get the number of the row, ie: 1 if is the first row.

Now, how can i retrieve a value of a field of that record??

Research the DLookup function.
 
To refrence a control on the Mainform(ParentForm) FROM a subform uses this syntax in VBA:

Me.Parent!ControlName

So I supose something like this could possible work:

Code:
Private SubForm OnCurrent()
Me.Parent!NameOfControl = Me!Controlname
End Sub

However I don't see the point in filling out a control on the ParentForm with data from a subformField.

To keep syncronisation you must put it in the OnCurrent event of the subform itself

JR
 
if you have a subform in a main form, then simply

subformcontrolname!fieldname in code in the mainform will resolve the appropriate detail of the currently selected row in the subform.

you need to handle the case where there are no records displayed, is all
 
if you have a subform in a main form, then simply

subformcontrolname!fieldname in code in the mainform will resolve the appropriate detail of the currently selected row in the subform.

you need to handle the case where there are no records displayed, is all


this was the easiest way, but i thank you all for your time helping me, it was much appreciated and i will sure try all the other ways when i have more time to practice.
 

Users who are viewing this thread

Back
Top Bottom