Set Focus to a Form on a Tab form (2 Viewers)

suzeg

Registered User.
Local time
Yesterday, 18:39
Joined
Jun 20, 2012
Messages
27
I have FormA,(frmstudentVouchers) on a Tab and it calls a pop-up form, FormB (frmUnAssignedVouchers).
I want to take the fields on formB and add them to the RecordSource of FormA which is a query.(qryStudentVocuhers)
The Code is below - I have indicated where it goes wrong. I have tried variations of DoCmd.Openorm & OpenQuery to no avail.

Thank you in advance for any help.

Private Sub Assigned_AfterUpdate()
Dim MyID As Variant
Dim MyVoucherNo As String
Dim MyIssueDate As Date
Dim MyExpires As Date
Dim MyComment As String
'The field Assigned is on FormB - Collecting data from FormB
If Assigned Then
MyID = Me.Parent!ID
MyVoucherNo = Me.VoucherID
MyIssueDate = Me.IssueDate
MyExpires = Me.Expires
MyComment = Me.Comments
'This is where it all goes wrong
'Go to New Record
DoCmd.Close acForm, "frmUnAssignedVouchers", acSaveYes

'Forms!["frmStudentVouchers"].SetFocus
DoCmd.OpenForm "frmStudentVouchers"
DoCmd.GoToRecord acDataForm, "frmStudentVouchers", acNewRec

'Add new data
Me.Parent.ID = MyID
Me.VoucherNo = MyVoucherNo
'Me.IssueDate = MyIssueDate
Me.Expires = MyExpires
Me.Comments = MyComment
End If
End Sub
 

Users who are viewing this thread

Top Bottom