Why is AfterUpdate Failing?

Bill Bisco

Custom User Title
Local time
Today, 04:38
Joined
Mar 27, 2009
Messages
92
On my Subform I have a textbox whose AfterUpdate Event runs a query that Updates the Value listed in the Textbox to a Table.

When this button is clicked the first time, the Table Value does not actually update. When Clicked a Second Time, the Table Value does update.

The VBA Code is:

Code:
Public Sub txtProcessSEQ_AfterUpdate()

    Dim qryName8 As String
    Dim qryName9 As String
    
    qryName8 = "qupdProcessSelectProposedSEQ" 
    qryName9 = "qupdProcessSelectCurrentSEQ" 
   
    
 '   DoCmd.SetWarnings False
   DoCmd.OpenQuery qryName8
    DoCmd.OpenQuery qryName9
    DoCmd.SetWarnings True

   Me.Parent.Refresh

End Sub

I've attached my database. To see what I'm talking about for yourself, under "View LS and RS Stations" Click the Combo Box and Choose Stations 1, 2, or 3. Try to change a SEQ, hit enter. Then exit the Form, and Open it up again.

Any help is appreciated.

Sincerely,
Bill
 

Attachments

I still don't know why AfterUpdate demands to be run twice. My current solution is to run my code once in AfterUpdate, and then again on Lose Focus. I tried using code only once on lose focus but for some reason it failed.

Any help is appreciated.

Sincerely,
Bill
 
Try saving the record first
 
Dear Rich,

I have tried adding
Code:
Public Sub txtProcessSEQ_AfterUpdate()

    Dim qryName8 As String
    Dim qryName9 As String
[COLOR=Blue]    Dim strFormName As String
    
    strFormName = "frmProcessSelectLSRS"[/COLOR]
    qryName8 = "qupdProcessSelectProposedSEQ" 
    qryName9 = "qupdProcessSelectCurrentSEQ" 
   
     [COLOR=Blue]DoCmd.Save acForm, strFormName    [/COLOR]

 '   DoCmd.SetWarnings False
   DoCmd.OpenQuery qryName8
    DoCmd.OpenQuery qryName9
    DoCmd.SetWarnings True

   Me.Parent.Refresh

   End Sub
the Form Name is the Name of the Main form on which the subform on which this control resides.

This hasn't worked for some reason. Is there another way to Save in VBA?

Sincerely,
Bill
 
That saves the form itself, not the data. Try

DoCmd.RunCommand acCmdSaveRecord

or

If Me.Dirty Then Me.Dirty = False
 
The first one did the trick. Thanks pbaldy! :D I have gained even more knowledge!

Sincerely,
Bill
 

Users who are viewing this thread

Back
Top Bottom