I am using the following code to add new records to a table that is on my Sub Form. Below is the code that I placed in my Before Update event on my Sub Form:
Expand|Select|Wrap|Line Numbers
- Private Sub Form_BeforeUpdate(Cancel As Integer)
- 'When records are added it adds the coresponding LocationsID, YearID and Month IDs
- 'to the new record.
- If Me.NewRecord Then
- JtnLocationsID = Forms!Forecastform!cboLocation
- YearID = Forms!Forecastform!CboYear
- MonthID = Forms!Forecastform!CboMonth
- End If
- End Sub
The LocationsID can be found in my following table:
Table Name :tblLocationsMM
Field Name = DivisionIDFK = Number
Field Name = WrkRegIDFK = Number
Field Name = CreditRegIDFK = Number
Field Name = LocationsID = AutoNumber
Like I mentioned, I am displaying the DivisionIDFK, WrkRegIDFK, CreditRegIDFK via three other controls on my form:
DivisionIDFK = cboDivision
WrkRegIDFK = cboWrkReg
CreditRegIDFK = cboCreditReg
My question is, instead of me referencing the control (cboLocation) on my form to get the LocationsID, is there a way that I code write the code to lookup the LocationsID based on my other controls on my form (cboDivision, cboWrkReg, cboCreditReg) that never blank out?
Any direction would be greatly appreciated
Thanks,
Keith.