code not working

S

SF

Hi,

I have a Main Form (for Organization) and subform (for detail individual
information). these two forms are linked by OrgID. In the detail form
(Tabular), I have a combobox for user to select the position, If user type
data that are not in the table, a Position form opemup for user to type new
information in, then the new information will reflect in the combobox
(position).

In my case, I face an error message with error code 2118 (You must save the
current field before requery)

I put this code in the Not in the list event of Position combobox

Private Sub Co_PositionID_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_Co_PositionID_NotInList

Dim intAnswer As Integer

intAnswer = MsgBox("Would you like to add this value to the list?", vbYesNo,
vbQuestion)
If intAnswer = vbYes Then
DoCmd.RunCommand acCmdUndo
DoCmd.OpenForm "frmFunction", acNormal, , , acFormAdd, acDialog
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If

Exit_Co_PositionID_NotInList:
Exit Sub

Err_Co_PositionID_NotInList:
MsgBox Err.Description
Resume Exit_Co_PositionID_NotInList

End Sub


In the frmPosition, on close event, I put the following:

If IsLoaded("frmEvenstParticipants") Then
''DoCmd.Save acForm, "frmEvenstParticipants"
Forms![frmEvenstParticipants]![frmContactSubform]![Co_PositionID].Requery
====> I get error here
End If
 
A

Allan Murphy

Remove the code from the CLOSE event in frmPosition and place the code

Forms![frmEvenstParticipants]![frmContactSubform]![Co_PositionID].Requery in
the Got Focus of the CO_PositionID
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top