Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

how to set value for bound text box column in VBA - access application project.

for an example - I have created 2 forms name like [mainFrm, subFrm], both forms having student details. I bound Student ID in text box. First I execute mainFrm by default first record will be shown. then selects some other record of student by navigating next/previous. and then I fire a command button event to call subFrm and here i need set id value to the subFrm which was in the mainFrm.


VB
Private Sub OpensubFrm_Button_Click()


        DoCmd.OpenForm "subFrm", acNormal, , "[Stud_ID] = " & Forms!mainFrm!Stud_ID

        Forms!subFrm!Stud_ID = Forms!mainFrm!Stud_ID

End Sub


I am getting error, "you cannot assign value to this object"

Help me!

Thanks in Advance


Regards,
Prakash.T
Posted

1 solution

Do you really have subform on mainform? I see that you're trying to open existing form as a separate window. In this case you can't bind data in this way. You need to dynamically change query / source of your subfrm or to write query which refer to mainfrm, something like this one:
SQL
SELECT *
FROM SecondTable
WHERE Stud_Id = Forms!MainFrm!Stud_ID


Please, follow these links:
Run a parameter query[^]
http://www.btabdevelopment.com/ts/frmrefinqry[^]
http://www.meadinkent.co.uk/accformparams.htm[^]
Current event [OnCurrent Property][^]
Create a subform[^]
 
Share this answer
 
Comments
Prakash Thirumoorthy 19-Mar-13 23:50pm    
its working fine .. thanks :-)
Maciej Los 20-Mar-13 2:50am    
You're welcome ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900