VBA Code Required to Update Field Value In Form B from Underlying Field Value Form A

vendredi 17 avril 2015

I have two forms, both of which have a field called JobID (Form A is the primary Key and Form B is the linked field - Relationship: One to Many).



Form A = FrmJobs

Form B = FrmPurchaseOrders



I have put a command button on Form A. When I click the button I need it to open Form B and then automatically fill the field JobID in Form B with the same value in Form A from which it was opened. I have tried the following:



Private Sub Command214_Click()

Me.Refresh

On Error GoTo Err_Command214_Click



Dim stDocName As String

Dim stLinkCriteria As String



stDocName = "FrmPurchaseOrders"

DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.GoToRecord , , acNewRec

Forms![FrmPurchaseOrders].[JobID] = Forms![FrmJobs].[JobID]



Exit_Command214_Click:

Exit Sub



Err_Command214_Click:

MsgBox Err.Description

Resume Exit_Command214_Click



End Sub




The above code works on my old database but not on my new database. I get the following message "Object does not support this property or method"



Does anyone know of any alternative code I could use to get the above to work?



Thanks David.

VBA Code Required to Update Field Value In Form B from Underlying Field Value Form A

0 commentaires:

Enregistrer un commentaire

Labels