Coding the Subform controls

N

Neo

Hello all,

I am new to VBA. I have a concern. I have a mainform and it contains
a subform.The subform contains 12 textboxes associated with their
label. Each text box is associated to a field of the table. I have to
add a new record to the table. The user has to enter the values in the
appropriate text boxes. When they click a command button called
"update"(this control is in the mainform"), the text boxes values will
be updated to the Table. similarly when the user searches for a
particular record and click Search button(this control is in the main
form), the record values should be displayed in the appropriate text
boxes.
I wrote a code to add a new record when the text boxes were in the main
form..But now i dont know how to get the values from the
textboxes,since they are in subform.
Can anyone help me , how to process the values from the Subform's
textboxes ??


Thanks in advance
Neo
 
M

Marshall Barton

Neo said:
I am new to VBA. I have a concern. I have a mainform and it contains
a subform.The subform contains 12 textboxes associated with their
label. Each text box is associated to a field of the table. I have to
add a new record to the table. The user has to enter the values in the
appropriate text boxes. When they click a command button called
"update"(this control is in the mainform"), the text boxes values will
be updated to the Table. similarly when the user searches for a
particular record and click Search button(this control is in the main
form), the record values should be displayed in the appropriate text
boxes.
I wrote a code to add a new record when the text boxes were in the main
form..But now i dont know how to get the values from the
textboxes,since they are in subform.
Can anyone help me , how to process the values from the Subform's
textboxes ??


Your situation is very confusing. Since you ssaid the
subform controls are bound to the subform's record source
table, the data in the subform will be saved to the table
when the focus moves back to the main form (i.e. when you
click any button) and before the code in your update button.
THis makes the whole idea of the button meaningless.

The main form can refer to a control in the subform using
this kind of syntax:
subformcontrolname.Form.controlname
 
N

Neo

Hi Marshall,

Thanks for your comments. Anyway i didnt set the record source for the
subform. I checked it and it works perfectly.


Thanks
Neo
 
M

Marshall Barton

Neo said:
Thanks for your comments. Anyway i didnt set the record source for the
subform. I checked it and it works perfectly.



An unbound subform is a bit unusual, and makes my comments
about saving the data irrelevant.

Glad you got it working.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top