update subform from form

edo janssen

Registered User.
Local time
Today, 16:24
Joined
Oct 29, 2010
Messages
16
I have a form with a subform. On the mainform I have some buttons. When I select a record on the subform and then I push a button on the mainform I want the record on the subform be updated with the data I put into the inputbox.

Below the code I already have to update the record on the subform. But unfortunately it doesn't work. Who can help me out with this?

Code:
Dim Message, Title, sInputW, sPercEigId
Message = "Voer de wijzigingsdatum in (dd-mm-jjjj)."
Title = "Wijzigingsdatum"    ' Stelt titel in.
sInputW = Inputbox(Message, Title)
sPercEigId = Forms("frmPerceelEigenaar").Controls("sfrmPerceelEigenaar").Form.Controls("PerceelEigenaar_id").Value
'MsgBox "Test " & sPercEigId

CurrentDb.Execute "UPDATE dbo_PerceelEigenaar SET dbo_PerceelEigenaar.Wijzigingsdatum = #" & sInputW & "# WHERE dbo_PerceelEigenaar.PerceelEigenaar_id= '" & sPercEigId & "';"
 
Last edited:
This line of code;
Code:
sPercEigId = Forms("frmPerceelEigenaar").Controls("sfrmPerceelEigenaar").Form.Controls("PerceelEigenaar_id").Value
Does not look quiet right :eek: Check this link for the correct syntax for referring to forms, subforms and their controls from various relative locations.

You certainly don't need the parenthesis and the double quotes.
 
Hi John,

Thanks for you input. I think the syntax is right. When I use msgbox to show the value of the syntax I get the value which belongs to the record on the subform.
 

Users who are viewing this thread

Back
Top Bottom