how do I go to new record in subform and auto fill data

G

Guest

I have a subform in a form that is called when the user dbl clicks a record
in another form which is a query based on data entered in an unbound form.

When I step through this code, I don't get any error messages, but when I am
returned to the form I don't have an added record with the data from the
unbound form.

Any suggestions? Thanks for your help.

Private Sub Form_Open(Cancel As Integer)
Dim strOpenCondition As String

' COMMENTS
'[frm scheduling-employees] is the main form of this subform
'main form record has correctly selected the proper record to edit based
on record selected on form [frm Scheduling - Employee Available] User
selected which employee to schedule
'populate field in schedule table based on fields on form [Frm
Scheduling - check Availability]
'END COMMENTS

If Not IsNull(Forms![frm Scheduling-Employees].OpenArgs) Then
strOpenCondition = Forms![frm Scheduling-Employees].OpenArgs
Select Case strOpenCondition
Case "addSCH"
RunCommand acCmdRecordsGoToNew
Me![sch start time].Value = Forms![Frm Scheduling - check
Availability].txtStart.Value
Me![SCH End Time].Value = Forms![Frm Scheduling - check
Availability].txtEnd.Value
Me![Monday].Value = Forms![Frm Scheduling - check
Availability].chkMonday.Value
Me![Tuesday].Value = Forms![Frm Scheduling - check
Availability].chkTuesday.Value
Me![Wednesday].Value = Forms![Frm Scheduling - check
Availability].chkWednesday.Value
Me![Thursday].Value = Forms![Frm Scheduling - check
Availability].chkThursday.Value
Me![Friday].Value = Forms![Frm Scheduling - check
Availability].chkFriday.Value
Me![Saturday].Value = Forms![Frm Scheduling - check
Availability].chkSaturday.Value
Me![Sunday].Value = Forms![Frm Scheduling - check
Availability].chkSunday.Value

Me![SCH-FK Client ID].SetFocus
End Select
End If
End Sub
 
G

Guest

I found the answer. I wasn't adding data to the key that linked the two
tables. I assumed it would be added like it is when the user manually adds a
new record on the form.... But I have another problem, the focus doesn't
remain on the record in the subform, it goes back to the main form. How do I
keep the focus on the record in the subform?
 

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