Code keeps deleting itself after error (1 Viewer)

Gr3g0ry

Registered User.
Local time
Today, 02:54
Joined
Oct 12, 2017
Messages
163
this is all the vba im currently using

Option Compare Database

Private Sub cboPaymentTerms_AfterUpdate()

If Me.cboPaymentTerms.Value = "Daily" Then
Me.txtMaturityBal.Value = Me.txtStartAmount * 5 * 4 * 6

ElseIf Me.cboPaymentTerms.Value = "Weekly" Then
Me.txtMaturityBal.Value = Me.txtStartAmount * 4 * 6

ElseIf Me.cboPaymentTerms.Value = "Fortnightly" Then
Me.txtMaturityBal.Value = Me.txtStartAmount * 2 * 6

ElseIf Me.cboPaymentTerms.Value = "Monthly" Then
Me.txtMaturityBal.Value = Me.txtStartAmount * 6

End If

Me.txtActualBalance.Value = Me.txtStartAmount.Value

End Sub

Private Sub txtStartDate_AfterUpdate()
Me.txtMaturityDate.Value = DateAdd("m", 6, Me.txtStartDate.Value)
End Sub

Public Function MaxPID()
MaxPID = CurrentDb.OpenRecordset("qryMaxPID").Fields(0)
End Function


when i try to save my file and exit i get the error "The Search key was not found in any record".

i get the Customer Id from my customer table via query
i get the new PartnerId from query +1 from partner table

why do i keep getting this error
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:54
Joined
May 7, 2009
Messages
19,169
Post qryMaxPID, so we may know
 

Gr3g0ry

Registered User.
Local time
Today, 02:54
Joined
Oct 12, 2017
Messages
163
SELECT Max(PARTNER.PartnerId) AS MaxOfPartnerId
FROM PARTNER;

this is the MaxPID query. i use this and add 1 to create my new partnerId
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:54
Joined
May 7, 2009
Messages
19,169
Dies partner table has record.
 

MarkK

bit cruncher
Local time
Today, 02:54
Joined
Mar 17, 2004
Messages
8,178
I have only seen that error, "The search key was not found in any record," as the result of corruption in the file. I would try a Compact & Repair and see if that makes a difference.
Mark
 

Gr3g0ry

Registered User.
Local time
Today, 02:54
Joined
Oct 12, 2017
Messages
163
lol lol lmao. sry i shouldnt even be laughing. i tried the compact & repair option in access and now i cant do anything in my file. :(

i had previous versions of my database stored so im gonna restart my forms.
if i get this error again then ill be back. thanks a million guys.

MarkK & arnelgp .... maximum respect
 

Users who are viewing this thread

Top Bottom