Talismanic
11-06-2000, 09:37 AM
I have a subform that is bound to a seperate table then the main form. The subform is a travel log, when the user types in travel an input box comes up asking for an amount. Everything is getting to the subform correctly. My problem is that the subform is not going to a new record when the main form does. So if I enter two records in a row and look at the travel subform or table it is modifying the data for the first entry instead of adding a new record. What do I need to do?
Richie
11-06-2000, 10:57 AM
How is table two linked to table one?
Talismanic
11-06-2000, 11:03 AM
I have them linked by three of the six fields in the subform. The other three fields of the subform are new data that gets added with the data from the input box.
Here is the code:
If RateTime = "FT" Then
intFootage = InputBox("Enter Footage Amount", "Footage Job!")
WeekTotal = Val([intFootage])
Me!frmTravel!Total = Me!WeekTotal
Me!frmTravel!EarnCode = 9
Me!frmTravel!PhaseCode = Me!PhaseCode
With CodeContextObject
.JobNumber.DefaultValue = """" & .JobNumber & """"
.JobName.DefaultValue = """" & .JobName & """"
.WeekEnding.DefaultValue = """" & .WeekEnding & """"
.EntryPerson.DefaultValue = """" & .EntryPerson & """"
.EmployeeNumber.DefaultValue = """" & .EmployeeNumber & """"
.LastName.DefaultValue = """" & .LastName & """"
.FirstName.DefaultValue = """" & .FirstName & """"
.Travel.DefaultValue = """" & .Travel & """"
End With
DoCmd.GoToControl "JobNumber"
DoCmd.GoToRecord acForm, "TimeSheetGR", acNewRec
End If
Is the last two lines of this code causing the problem?
[This message has been edited by Talismanic (edited 11-06-2000).]
Richie
11-06-2000, 02:20 PM
I'm not sure I understand what you are trying to do are you saying that If rate time = FT you want to go to a new record?
And what is all the with code for?
Pat Hartman
11-06-2000, 03:24 PM
Access will control keeping the two forms in sync if the master/child links are set properly. You do not need any code or filters to make this happen.
Talismanic
11-07-2000, 04:56 AM
The With code is to fill the next record with the previous records values by default.
I am not having any problem with that form/subform . I am having trouble with another subform. I think that I am setting the focus back to the main forms first control without updating the subforms information because when I type more information in the main form the previous data is still in the subform.
It doesnt go to a new record and the information in the subform changes based on the new entries.
I have the forms linked right so how can a force a new record in a subform with a On_Exit Event of a control on my main form.