field from subform (datasheet) to appear in a textbox on the form

P

postman

I want a field from subform (datasheet) to appear in a textbox on the form.

I have a comments field with several lines of text, so its not practical to
have it shown in datasheet view on my form. I want the comments field to
appear in a text box below the datasheet subform.

But the textbox's control source =[comments] reads the "first" record's
comment field even when I move down to another record in the subform
datasheet, when it should read the new records comment field.

I have tried placing a textbox in the subform, & directing the form textbox
to it, but still not work.

Any ideas...

Thanks.
 
D

Duane Hookom

You can add code to the On Current event of the subform like:
Private Sub Form_Current()
Me.Parent.txtComments = Me.txtComments
End Sub
 
P

postman

Sorry that threw a compile error, why...I dunno.
Should I put that in the Form or open the subform and put it there?
Thanks.

Duane Hookom said:
You can add code to the On Current event of the subform like:
Private Sub Form_Current()
Me.Parent.txtComments = Me.txtComments
End Sub

--
Duane Hookom
MS Access MVP


postman said:
I want a field from subform (datasheet) to appear in a textbox on the
form.

I have a comments field with several lines of text, so its not practical
to
have it shown in datasheet view on my form. I want the comments field to
appear in a text box below the datasheet subform.

But the textbox's control source =[comments] reads the "first" record's
comment field even when I move down to another record in the subform
datasheet, when it should read the new records comment field.

I have tried placing a textbox in the subform, & directing the form
textbox
to it, but still not work.

Any ideas...

Thanks.
 
D

Duane Hookom

My reply assumed you had a control on your subform named txtComments and a
control on your main form named txtComments. Did you leave this code as was?
Do you have controls with different names?

Leave the code in the On Current event of the subform.

--
Duane Hookom
MS Access MVP


postman said:
Sorry that threw a compile error, why...I dunno.
Should I put that in the Form or open the subform and put it there?
Thanks.

Duane Hookom said:
You can add code to the On Current event of the subform like:
Private Sub Form_Current()
Me.Parent.txtComments = Me.txtComments
End Sub

--
Duane Hookom
MS Access MVP


postman said:
I want a field from subform (datasheet) to appear in a textbox on the
form.

I have a comments field with several lines of text, so its not practical
to
have it shown in datasheet view on my form. I want the comments field to
appear in a text box below the datasheet subform.

But the textbox's control source =[comments] reads the "first" record's
comment field even when I move down to another record in the subform
datasheet, when it should read the new records comment field.

I have tried placing a textbox in the subform, & directing the form
textbox
to it, but still not work.

Any ideas...

Thanks.
 
P

postman

Won't work...throws an error,
I put the code in the On Current event of the subform:

Private Sub Form_Current()
DoCmd.RunCommand acCmdSelectRecord
Me.Parent.txtComments = Me.txtComments
End Sub
The first row is code to enable a row select automatically, which is not
relevant to this 'comments' operation.
I renamed the control on the subform footer to txtComments, & set its data
source to Comments which is the name of the comments field.
I renamed the control on the main form to txtComments.

Thanks.

Duane Hookom said:
My reply assumed you had a control on your subform named txtComments and a
control on your main form named txtComments. Did you leave this code as
was? Do you have controls with different names?

Leave the code in the On Current event of the subform.

--
Duane Hookom
MS Access MVP


postman said:
Sorry that threw a compile error, why...I dunno.
Should I put that in the Form or open the subform and put it there?
Thanks.

Duane Hookom said:
You can add code to the On Current event of the subform like:
Private Sub Form_Current()
Me.Parent.txtComments = Me.txtComments
End Sub

--
Duane Hookom
MS Access MVP


I want a field from subform (datasheet) to appear in a textbox on the
form.

I have a comments field with several lines of text, so its not
practical to
have it shown in datasheet view on my form. I want the comments field
to
appear in a text box below the datasheet subform.

But the textbox's control source =[comments] reads the "first" record's
comment field even when I move down to another record in the subform
datasheet, when it should read the new records comment field.

I have tried placing a textbox in the subform, & directing the form
textbox
to it, but still not work.

Any ideas...

Thanks.
 
D

Duane Hookom

I would have expected the subform txtComments to be in the detail section.
Also, what error gets thrown?
Is the main form txtComments unbound?

--
Duane Hookom
MS Access MVP


postman said:
Won't work...throws an error,
I put the code in the On Current event of the subform:

Private Sub Form_Current()
DoCmd.RunCommand acCmdSelectRecord
Me.Parent.txtComments = Me.txtComments
End Sub
The first row is code to enable a row select automatically, which is not
relevant to this 'comments' operation.
I renamed the control on the subform footer to txtComments, & set its data
source to Comments which is the name of the comments field.
I renamed the control on the main form to txtComments.

Thanks.

Duane Hookom said:
My reply assumed you had a control on your subform named txtComments and
a control on your main form named txtComments. Did you leave this code as
was? Do you have controls with different names?

Leave the code in the On Current event of the subform.

--
Duane Hookom
MS Access MVP


postman said:
Sorry that threw a compile error, why...I dunno.
Should I put that in the Form or open the subform and put it there?
Thanks.

You can add code to the On Current event of the subform like:
Private Sub Form_Current()
Me.Parent.txtComments = Me.txtComments
End Sub

--
Duane Hookom
MS Access MVP


I want a field from subform (datasheet) to appear in a textbox on the
form.

I have a comments field with several lines of text, so its not
practical to
have it shown in datasheet view on my form. I want the comments field
to
appear in a text box below the datasheet subform.

But the textbox's control source =[comments] reads the "first"
record's
comment field even when I move down to another record in the subform
datasheet, when it should read the new records comment field.

I have tried placing a textbox in the subform, & directing the form
textbox
to it, but still not work.

Any ideas...

Thanks.
 
P

postman

The subform (datasheet view) txtComments ctextbox is in the footer section
to hide it, if in detail section I get two occurrences of the Comments
field.

The Error thrown is: Run-time error '-2147352567 (80020009)':
You can't assign a value to this object.

It occurs upon opening the main form and is persistent.

No the main forms txtComments control source
=[ds-qry_dB_MUSIC_Search].Form!txtComments.

Thanks.


Duane Hookom said:
I would have expected the subform txtComments to be in the detail section.
Also, what error gets thrown?
Is the main form txtComments unbound?

--
Duane Hookom
MS Access MVP


postman said:
Won't work...throws an error,
I put the code in the On Current event of the subform:

Private Sub Form_Current()
DoCmd.RunCommand acCmdSelectRecord
Me.Parent.txtComments = Me.txtComments
End Sub
The first row is code to enable a row select automatically, which is not
relevant to this 'comments' operation.
I renamed the control on the subform footer to txtComments, & set its
data source to Comments which is the name of the comments field.
I renamed the control on the main form to txtComments.

Thanks.

Duane Hookom said:
My reply assumed you had a control on your subform named txtComments and
a control on your main form named txtComments. Did you leave this code
as was? Do you have controls with different names?

Leave the code in the On Current event of the subform.

--
Duane Hookom
MS Access MVP


Sorry that threw a compile error, why...I dunno.
Should I put that in the Form or open the subform and put it there?
Thanks.

You can add code to the On Current event of the subform like:
Private Sub Form_Current()
Me.Parent.txtComments = Me.txtComments
End Sub

--
Duane Hookom
MS Access MVP


I want a field from subform (datasheet) to appear in a textbox on the
form.

I have a comments field with several lines of text, so its not
practical to
have it shown in datasheet view on my form. I want the comments field
to
appear in a text box below the datasheet subform.

But the textbox's control source =[comments] reads the "first"
record's
comment field even when I move down to another record in the subform
datasheet, when it should read the new records comment field.

I have tried placing a textbox in the subform, & directing the form
textbox
to it, but still not work.

Any ideas...

Thanks.
 

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