Hello,
I have faced some weird challenges with the Dlast function I am using in a form.
Private Sub txtHonaID_Exit(Cancel As Integer)
Dim BurNr As Integer
BurNr = Nz(DLast("BurNr", "tblParn2010") + 1, 1)
Me.cboBurNr = BurNr
End If
End Sub
This is basically the event from the form. So what happens is that the form looks for the last "BurNr" field in the last inserted record in table [tblParn2010], and adds +1, and inserts it into my Combobox "cboBurNr" inside the form. If the latest number was 40, the next record to be inserted will get 41 as value for field "BurNr".
This usually works perfect, but at some point entering data to the form the number can stop updating. The number can e.g. stop at 35 and all the records entered after that will be 35. Even if i manually go into the table and change the latest value to e.g. 50, the form anyhow picks up 35. It feels like the (in this case) number "34" somehow is stored in the memory of the Dlast function.
I have to point out that I'm not trying to achieve an autonumber system with this function. It is neither anything that needs to be unique (BurNr field). I want to have it running in the form so i can manually change it whenever I want e.g. to 500, and the form picks it up and continues with 501, 502 etc.
Anyone know what could cause this problem, or is there perhaps a better function to use?
I have faced some weird challenges with the Dlast function I am using in a form.
Private Sub txtHonaID_Exit(Cancel As Integer)
Dim BurNr As Integer
BurNr = Nz(DLast("BurNr", "tblParn2010") + 1, 1)
Me.cboBurNr = BurNr
End If
End Sub
This is basically the event from the form. So what happens is that the form looks for the last "BurNr" field in the last inserted record in table [tblParn2010], and adds +1, and inserts it into my Combobox "cboBurNr" inside the form. If the latest number was 40, the next record to be inserted will get 41 as value for field "BurNr".
This usually works perfect, but at some point entering data to the form the number can stop updating. The number can e.g. stop at 35 and all the records entered after that will be 35. Even if i manually go into the table and change the latest value to e.g. 50, the form anyhow picks up 35. It feels like the (in this case) number "34" somehow is stored in the memory of the Dlast function.
I have to point out that I'm not trying to achieve an autonumber system with this function. It is neither anything that needs to be unique (BurNr field). I want to have it running in the form so i can manually change it whenever I want e.g. to 500, and the form picks it up and continues with 501, 502 etc.
Anyone know what could cause this problem, or is there perhaps a better function to use?