Fill a primary key from a linked table

L'apprentis

Redcifer
Local time
Today, 15:20
Joined
Jun 22, 2005
Messages
177
I am not entirely sure that i am in the right place in the forum but my question is concerning updating data via a form so i hope it will be ok.
I have a 'product' table linked to a 'batch received table' with a 1 to many relationship.
I wanted the employee to fill the 'batch received form' (where all information about the item received are entered on the form and a 'transaction table' subform) when an item is received instead of calling the 'product form' for each item.
Obviously, when the item received is not registered in the 'product table' a Broken join error occurs.
I was thinking of putting a code in the 'on the error event' of the 'batch received form' requesting the user to register the product first with the 'product form' coming on the screen once the error text box closed.
Once the new value entered, the form is still stuck and i can't save new data with the product unless I close and reopen the form.

Here is my error code

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim Msg As String, NewLine As String
Const ERR_BROKENJOIN = 3101
Const ERR_NULLKEY = 3058
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Item"
NewLine = Chr$(13) & Chr$(10)

Select Case DataErr
Case ERR_BROKENJOIN
Msg = "You need to Register the product first to be able to proceed"
MsgBox Msg
Response = DATA_ERRCONTINUE
End Select


DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec

End Sub

I have try to requery the form but it still not working.
I am just starting VBA and would be gratefull for any advice, thanks.
 

Users who are viewing this thread

Back
Top Bottom