Hi,
I was just trying to improve one of my forms this morning, and I've hit a stumbling block. I can upload the database if necessary, but I'm hoping it's something simple you can help without it first.
Basically, I changed the form so that it communicates with a query, instead of the table. I have a button that when you click on it, it takes you to the following code. The code worked perfectly before I tampered with the form! I'm sure it's self explanatory, but it should add the information from the form to the query, and the EngagemenText_PK is one number higher than the previous.
Code:
Private Sub Command6_Click()
Dim x, y, test As Integer
Dim rs As DAO.Recordset
DoCmd.GoToRecord , , acNewRec
Set rs = CurrentDb.OpenRecordset("SELECT EngagementsText_PK FROM Q_Engagements", dbOpenSnapshot)
With rs
.MoveLast
x = Nz(![EngagementsText_PK], "")
x = Int(x + 1)
If Len([EngagementsText_PK] & "") = 0 Then
Me.EngagementsText_PK = x
End If
Date_of_Remit.SetFocus
End With
End Sub
It brings up the error message "Cannot add record(s); join key of table ‘T_Engagements’ not in recordset".
I'm not sure why that's happening, or how to solve it.
Many thanks in advance for any help.