Query not finding new data

Autoeng

Why me?
Local time
Today, 18:01
Joined
Aug 13, 2002
Messages
1,302
I have a report that receives data from a query but recently when I enter new data into the database the query is not picking up the new data until the record is exited and reentered. I have code in to generate a sequence number for each record entered into a subform of the form so that the subform records are displayed in a particular order (ascending according to the sequence number). This code was generated by a paid programmer and is the only thing of late to have changed but I am not getting any response from the programmer. Needless to say, it is the last I'll do business with him.

Is there anything here that could be causing the problem or what can I look at that might be the likely culpret?

On Current Event of the main form
Code:
Private Sub Form_Current()
    Dim varLookup As Variant
    Me.Seq = 0
    If Forms![frmMain].[ECNID] <> "" Then
        varLookup = DMax("Seq", "tblECNParts", "[ECNID]= " & Forms![frmMain].[ECNID])
        If Not IsNull(varLookup) Then
            Me.Seq = CByte(varLookup)
        End If
    End If

End Sub


Before Insert Event of the subform
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
    
    Forms!frmMain.Seq = Forms!frmMain.Seq + 1
    Me.Seq = Forms!frmMain.Seq
    
End Sub

Thanks,
Autoeng
 
If you are entering data in a form, you must leave a record before it will save to a table. It sounds like your report is triggered from your entry form, so you should either leave the last record, or save the last record entered just before you run the report. You can save the record using this command:

DoCmd.RunCommand acCmdSaveRecord
 
How come I never had to do this before? I don't have a save record button and never had any problem before with the query pulling information without exiting. I thought that the great thing about Access was that everything happened in real time.

Autoeng
 

Users who are viewing this thread

Back
Top Bottom