Access 2003-you must save the current field before you run the requery action

bjgoen

New member
Local time
Today, 13:10
Joined
Feb 24, 2011
Messages
6
I had the following code in 2000. Recently updated to 2003. Now when you enter information you get "you must save the current field before you run the requery action"

If IsLoaded("frmProperties") Then
Forms![frmProperties]![frmPropertiesTitleCompanies].Form![txtTitleCompany].Requery
DoCmd.Close
Forms![frmProperties]![frmPropertiesTitleCompanies].Form![txtTitleCompany].Requery
Else
DoCmd.Close
End If

Attemped to do this (have this code on 2 different sub forms - one for Title Companies, one for Mortgage companies)

Set ctlCombo = Forms![frmProperties]![frmPropertiesMortgageCompanies].Form![txtMortgageCompany]

DoCmd.Save
If IsLoaded("frmProperties") Then
If Me.Dirty = True Then Me.Dirty = False
ctlCombo.Requery
DoCmd.Close
ctlCombo.Requery
Else
DoCmd.Close
End If

I don't know what I am doing wrong as this has never been an issue in the past.

Thanking you in advance for any help
 
Sorry -
This is on a command button (close).
Main form - frmProperties
Subform - frmPropertiesMortgageCompanies
Subform Control - txtMortgageCompany

txtMortgageCompany_NotInList opens frmMortgageCompanies.
after filling out the information and click on the Close button get ""you must save the current field before you run the requery action"
Can't close form without Xing out which does not save information just entered.

Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click
Dim ctlCombo As Control

' Return Control object pointing to a combo box.
Set ctlCombo = Forms![frmProperties]![frmPropertiesMortgageCompanies].Form![txtMortgageCompany]

If IsLoaded("frmProperties") Then
ctlCombo.Requery
DoCmd.Close
ctlCombo.Requery
Else
DoCmd.Close
End If

Exit_cmdClose_Click:
Exit Sub

Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click

End Sub

This is what the original code looked like until I started trying different things to make it work:

If IsLoaded("frmProperties") Then
Forms![frmProperties]![frmPropertiesMortgageCompanies].Form![txtMortgageCompany].Requery
DoCmd.Close
Forms![frmProperties]![frmPropertiesMortgageCompanies].Form![txtMortgageCompany].Requery
Else
DoCmd.Close
End If

This worked for years in Access 2000, but not working in 2003.
 
As stated in title - I am using 2003.
The problem in not in the NotInList code, but thanks for the information:

Private Sub txtMortgageCompany_NotInList(NewData As String, Response As Integer)
Dim strMessage As String
Dim db As Database
Dim rs As Recordset

strMessage = "Are you sure you want to add '" & NewData & _
"' to the list of Mortgage Companies?"

If Confirm(strMessage) Then
DoCmd.OpenForm "frmMortgageCompanies", , , , acFormAdd, acDialog
Response = acDataErrAdded
Else
If MsgBox(NewData & " is not a Mortgage Company in the list. " & vbCrLf & _
"Please pick a Mortgage Company from the list.", vbOKOnly) = vbOK Then
Me!txtMortgageCompany.Undo
Response = acDataErrDisplay
End If
End If
End Sub
 
As stated in title - I am using 2003.
The problem in not in the NotInList code, but thanks for the information:

Private Sub txtMortgageCompany_NotInList(NewData As String, Response As Integer)
Dim strMessage As String
Dim db As Database
Dim rs As Recordset

strMessage = "Are you sure you want to add '" & NewData & _
"' to the list of Mortgage Companies?"

If Confirm(strMessage) Then
DoCmd.OpenForm "frmMortgageCompanies", , , , acFormAdd, acDialog
Response = acDataErrAdded
Else
If MsgBox(NewData & " is not a Mortgage Company in the list. " & vbCrLf & _
"Please pick a Mortgage Company from the list.", vbOKOnly) = vbOK Then
Me!txtMortgageCompany.Undo
Response = acDataErrDisplay
End If
End If
End Sub

Did you ever get this working? I'm having the same problem. I'm basically doing the same for contacts. i.e. if the contact is not in the list I bring up a form to add them and on closing getting same error as you did.
 

Users who are viewing this thread

Back
Top Bottom