Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Value from Main form to Subform

Status
Not open for further replies.

Tash

MIS
Nov 3, 2001
62
US
I would like to paste the value of one field on a Main form into selected records in it's subform. I have a button that I click which then executes the "Set Value" option, however, only the first record's field populates. How can I make this work?
 
How are ya Tash . . .
Tash said:
[blue]I would like to paste the value of one field on a Main form into selected records in it's subform.[/blue]
[ol][li]Are you talking [blue]a specific field of a specific column of a specific record[/blue] in the mainform?[/li]
[li]How are you determining [blue]which field & column of the mainform?[/blue][/li]
[li]How are you determining [blue]which records & fields on the subform?[/blue][/li][/ol]

Calvin.gif
See Ya! . . . . . .
 
I have a Main form that is bound to a table called Invoices, the subform is based off a query and filtered with the information collected on a previous screen (Vendor, start date, end date).

What I want to do is take the Invoice number that appears on the Main form and paste it into an Invoice field on the related subform records. I don't have the two forms linked together. If the Main form's Invoice is #12345, then I want the ability to paste that Invoice number into the subform records that were queried off the previous screen. Thanks!
 
What is the actual code of your buton's Click event procedure ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Ok, now that I have been troubleshooting the issue, the error that I am getting is that my recordset is not updatable, which makes sense, since I can't even manually type in the field. Is this because my Main and Subform are not linked together? This is the code I am using:

Function GenerateInvoice()
On Error GoTo GenerateInvoice_Err

With CodeContextObject
.InvStartDate = Forms!FormPrintInvoice EnterBeginningDate
.InvEndDate = Forms!FormPrintInvoice!EnterEndDate
.InvStore = Forms!FormPrintInvoice!Enterstore
.SubformGenerateInv.Form!InvoiceNumber = .InvoiceID

End With

The part of it that is not working is the last line relating to the subform.
 
Ok, thanks for that information! I now have the updatable records problem solved, now I am back to my original problem of only being able to update one record instead of all the records that are selected. I am still using the code above. Any suggestions?
 
A starting point:
Dim rs As DAO.Recordset
...
Set rs = .SubformGenerateInv.Form.Recordset
rs.MoveFirst
While Not rs.EOF
.SubformGenerateInv.Form!InvoiceNumber = .InvoiceID
.MoveNext
WEnd
Set rs = Nothing
End With

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top