Thanks for your answer,
I thought about your suggestion, I didn't understand it quite well because the Key would be changing every time, since the combination of operator, station and date can be selected by the user, the form should go to the table and find record with the key where that combination exists. Nevertheless that gave me an idea:
- In query I created column [RowNum] with this calculation: RowNum: DCount("[ScheduleID]","[tblSchedule]","[ScheduleID]<=" & [ScheduleID])
- Then in [frmMain] I created a textbox [txtRowNum] with this formula in control source:
Code:
=IIf(IsNull([cmbStation]),"",IIf([txtSchedule]="Nule","",
DLookUp("[RowNum]","[Qry-ScheduledStatus]","([Station]='" & [cmbStation] & "') And
([Operador]='" & [lstDesig] & "') And ([ScheduledDate]=#" & [txtSchedule] & "#)")))
- Finally in the Private Sub Form Load event of the [frmEditSchedule] I used this code:
Code:
If Forms!frmMain![txtSchedule] = "Nule" Then
DoCmd.GoToRecord , , acNewRec
Else
DoCmd.GoToRecord , , acGoTo, Forms!frmMain!txtRowNum
End If