Update Query does not clear all records immediately

Hi All,

I have a form on which there are several "Flag" text fields which users use 
to mark records.  Next to each flag field there is a clear button that runs 
the following code:

Private Sub btn_ClSA1Flag1_Click()
On Error GoTo Err_btn_ClSA1Flag1_Click

    Dim stDocName As String

    stDocName = "QryUpd_ClearSA1Flag1"
    DoCmd.OpenQuery stDocName, acNormal, acEdit
    Me.Requery
    'DoCmd.OpenQuery stDocName, acNormal, acEdit


Exit_btn_ClSA1Flag1_Click:
    Exit Sub

Err_btn_ClSA1Flag1_Click:
    msgbox Err.Description
    Resume Exit_btn_ClSA1Flag1_Click
    
End Sub


As it is, if I am in the last record that was "Flagged" and I click on the 
clear button, that records Flag field does not get cleared.  But when I 
uncomment the second docmd.runquery (which runs the update query that clears 
the flag field) it clears everything because I am no longer on the last 
flagged records flag field.  How do I get the last flagged field cleared, 
without having to move off of the record and running the docmd.runquery 
twice??

Thanks for your help.

Emma
-- 
www.bardpv.com
Tempe, Arizona
0
Utf
6/27/2007 11:52:00 PM
access.formscoding 7493 articles. 0 followers. Follow

7 Replies
1060 Views

Similar Articles

[PageSpeed] 34

Is there any chance the current record in the form might be unsaved?

Assuming your form is bound, try inserting this code on a new line after the 
DIM line:
    If Me.Dirty Then Me.Dirty = False

Instead of OpenQuery, you could also try this:
    dbEngine(0)(0).Execute stDocName, dbFailOnError
which should notify you if the query is not able to update all the records. 
For an explanation of this, see:
    Action queries: suppressing dialogs, while knowing results
at:
    http://allenbrowne.com/ser-60.html

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Emma Aumack" <emma.aumack@crbard.com> wrote in message
news:4EC3EC7A-4B44-49CA-9C5A-D8877ECD03B4@microsoft.com...
> Hi All,
>
> I have a form on which there are several "Flag" text fields which users 
> use
> to mark records.  Next to each flag field there is a clear button that 
> runs
> the following code:
>
> Private Sub btn_ClSA1Flag1_Click()
> On Error GoTo Err_btn_ClSA1Flag1_Click
>
>    Dim stDocName As String
>
>    stDocName = "QryUpd_ClearSA1Flag1"
>    DoCmd.OpenQuery stDocName, acNormal, acEdit
>    Me.Requery
>    'DoCmd.OpenQuery stDocName, acNormal, acEdit
>
>
> Exit_btn_ClSA1Flag1_Click:
>    Exit Sub
>
> Err_btn_ClSA1Flag1_Click:
>    msgbox Err.Description
>    Resume Exit_btn_ClSA1Flag1_Click
>
> End Sub
>
>
> As it is, if I am in the last record that was "Flagged" and I click on the
> clear button, that records Flag field does not get cleared.  But when I
> uncomment the second docmd.runquery (which runs the update query that 
> clears
> the flag field) it clears everything because I am no longer on the last
> flagged records flag field.  How do I get the last flagged field cleared,
> without having to move off of the record and running the docmd.runquery
> twice??
>
> Thanks for your help.
>
> Emma
> -- 
> www.bardpv.com
> Tempe, Arizona 

0
Allen
6/28/2007 2:06:26 AM
On Jun 28, 6:06 am, "Allen Browne" <AllenBro...@SeeSig.Invalid> wrote:
> Is there any chance the current record in the form might be unsaved?
>
> Assuming your form is bound, try inserting this code on a new line after the
> DIM line:
>     If Me.Dirty Then Me.Dirty = False
>
> Instead of OpenQuery, you could also try this:
>     dbEngine(0)(0).Execute stDocName, dbFailOnError
> which should notify you if the query is not able to update all the records.
> For an explanation of this, see:
>     Action queries: suppressing dialogs, while knowing results
> at:
>    http://allenbrowne.com/ser-60.html
>
> --
> Allen Browne - Microsoft MVP.  Perth, Western Australia
> Tips for Access users -http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Emma Aumack" <emma.aum...@crbard.com> wrote in message
>
> news:4EC3EC7A-4B44-49CA-9C5A-D8877ECD03B4@microsoft.com...
>
> > Hi All,
>
> > I have a form on which there are several "Flag" text fields which users
> > use
> > to mark records.  Next to each flag field there is a clear button that
> > runs
> > the following code:
>
> > Private Sub btn_ClSA1Flag1_Click()
> > On Error GoTo Err_btn_ClSA1Flag1_Click
>
> >    Dim stDocName As String
>
> >    stDocName = "QryUpd_ClearSA1Flag1"
> >    DoCmd.OpenQuery stDocName, acNormal, acEdit
> >    Me.Requery
> >    'DoCmd.OpenQuery stDocName, acNormal, acEdit
>
> > Exit_btn_ClSA1Flag1_Click:
> >    Exit Sub
>
> > Err_btn_ClSA1Flag1_Click:
> >    msgbox Err.Description
> >    Resume Exit_btn_ClSA1Flag1_Click
>
> > End Sub
>
> > As it is, if I am in the last record that was "Flagged" and I click on the
> > clear button, that records Flag field does not get cleared.  But when I
> > uncomment the second docmd.runquery (which runs the update query that
> > clears
> > the flag field) it clears everything because I am no longer on the last
> > flagged records flag field.  How do I get the last flagged field cleared,
> > without having to move off of the record and running the docmd.runquery
> > twice??
>
> > Thanks for your help.
>
> > Emma
> > --
> >www.bardpv.com
> > Tempe, Arizona

First save the record and then do what you want to do,
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
when you don't save the record, it will load the old data from the
table and will not notice the changes you made in the form.

0
Naeem
6/28/2007 6:46:42 AM
Thank you Allen!

I like your code much better.  However, I am getting an error in the SQL 
Update statement.  Think you could help me out?  Quotations just kill me.

Please see the updated code below:

Private Sub btn_ClFlag_Click()
On Error GoTo Err_btn_ClFlag_Click

    Dim strSQL As String
    Dim flgField As String
    
    flgField = InputBox("Enter Flag #:", "Flag Field")
    txtFlgfield = InputBox("Enter Flag Criteria to be Cleared.  i.e.", 
"Clear Flag" & flgField)
        
    If Me.Dirty Then
        Me.Dirty = False
    End If
       
    strSQL = "UPDATE Tbl_Contacts SET Tbl_Contacts.Flag" & _
        flgField & "WHERE (((Tbl_Contacts.Flag" & flgField & ") = " & 
txtFlgField & "));"
    
    DBEngine(0)(0).Execute strSQL, dbFailOnError
    
    Me.Requery


Exit_btn_ClFlag_Click:
    Exit Sub
 
Err_btn_ClFlag_Click:
    msgbox Err.Description
    Resume Exit_btn_ClFlag_Click
    
End Sub

Thank you again!

-- 
www.bardpv.com
Tempe, Arizona


"Allen Browne" wrote:

> Is there any chance the current record in the form might be unsaved?
> 
> Assuming your form is bound, try inserting this code on a new line after the 
> DIM line:
>     If Me.Dirty Then Me.Dirty = False
> 
> Instead of OpenQuery, you could also try this:
>     dbEngine(0)(0).Execute stDocName, dbFailOnError
> which should notify you if the query is not able to update all the records. 
> For an explanation of this, see:
>     Action queries: suppressing dialogs, while knowing results
> at:
>     http://allenbrowne.com/ser-60.html
> 
> -- 
> Allen Browne - Microsoft MVP.  Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
> 
> "Emma Aumack" <emma.aumack@crbard.com> wrote in message
> news:4EC3EC7A-4B44-49CA-9C5A-D8877ECD03B4@microsoft.com...
> > Hi All,
> >
> > I have a form on which there are several "Flag" text fields which users 
> > use
> > to mark records.  Next to each flag field there is a clear button that 
> > runs
> > the following code:
> >
> > Private Sub btn_ClSA1Flag1_Click()
> > On Error GoTo Err_btn_ClSA1Flag1_Click
> >
> >    Dim stDocName As String
> >
> >    stDocName = "QryUpd_ClearSA1Flag1"
> >    DoCmd.OpenQuery stDocName, acNormal, acEdit
> >    Me.Requery
> >    'DoCmd.OpenQuery stDocName, acNormal, acEdit
> >
> >
> > Exit_btn_ClSA1Flag1_Click:
> >    Exit Sub
> >
> > Err_btn_ClSA1Flag1_Click:
> >    msgbox Err.Description
> >    Resume Exit_btn_ClSA1Flag1_Click
> >
> > End Sub
> >
> >
> > As it is, if I am in the last record that was "Flagged" and I click on the
> > clear button, that records Flag field does not get cleared.  But when I
> > uncomment the second docmd.runquery (which runs the update query that 
> > clears
> > the flag field) it clears everything because I am no longer on the last
> > flagged records flag field.  How do I get the last flagged field cleared,
> > without having to move off of the record and running the docmd.runquery
> > twice??
> >
> > Thanks for your help.
> >
> > Emma
> > -- 
> > www.bardpv.com
> > Tempe, Arizona 
> 
> 
0
Utf
6/28/2007 4:38:02 PM
To get a sample SQL statement, you can mock up a query and switch to SQL 
View (View menu.)

For an explanation of how to handle the quotes, see:
    Quotation marks within quotes
at:
    http://allenbrowne.com/casu-17.html

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Emma Aumack" <emma.aumack@crbard.com> wrote in message
news:6697239B-A57D-4340-8678-5155F8D9678B@microsoft.com...
> Thank you Allen!
>
> I like your code much better.  However, I am getting an error in the SQL
> Update statement.  Think you could help me out?  Quotations just kill me.
>
> Please see the updated code below:
>
> Private Sub btn_ClFlag_Click()
> On Error GoTo Err_btn_ClFlag_Click
>
>    Dim strSQL As String
>    Dim flgField As String
>
>    flgField = InputBox("Enter Flag #:", "Flag Field")
>    txtFlgfield = InputBox("Enter Flag Criteria to be Cleared.  i.e.",
> "Clear Flag" & flgField)
>
>    If Me.Dirty Then
>        Me.Dirty = False
>    End If
>
>    strSQL = "UPDATE Tbl_Contacts SET Tbl_Contacts.Flag" & _
>        flgField & "WHERE (((Tbl_Contacts.Flag" & flgField & ") = " &
> txtFlgField & "));"
>
>    DBEngine(0)(0).Execute strSQL, dbFailOnError
>
>    Me.Requery
>
>
> Exit_btn_ClFlag_Click:
>    Exit Sub
>
> Err_btn_ClFlag_Click:
>    msgbox Err.Description
>    Resume Exit_btn_ClFlag_Click
>
> End Sub
>
> Thank you again!
>
> -- 
> www.bardpv.com
> Tempe, Arizona
>
>
> "Allen Browne" wrote:
>
>> Is there any chance the current record in the form might be unsaved?
>>
>> Assuming your form is bound, try inserting this code on a new line after 
>> the
>> DIM line:
>>     If Me.Dirty Then Me.Dirty = False
>>
>> Instead of OpenQuery, you could also try this:
>>     dbEngine(0)(0).Execute stDocName, dbFailOnError
>> which should notify you if the query is not able to update all the 
>> records.
>> For an explanation of this, see:
>>     Action queries: suppressing dialogs, while knowing results
>> at:
>>     http://allenbrowne.com/ser-60.html
>>
>> -- 
>> Allen Browne - Microsoft MVP.  Perth, Western Australia
>> Tips for Access users - http://allenbrowne.com/tips.html
>> Reply to group, rather than allenbrowne at mvps dot org.
>>
>> "Emma Aumack" <emma.aumack@crbard.com> wrote in message
>> news:4EC3EC7A-4B44-49CA-9C5A-D8877ECD03B4@microsoft.com...
>> > Hi All,
>> >
>> > I have a form on which there are several "Flag" text fields which users
>> > use
>> > to mark records.  Next to each flag field there is a clear button that
>> > runs
>> > the following code:
>> >
>> > Private Sub btn_ClSA1Flag1_Click()
>> > On Error GoTo Err_btn_ClSA1Flag1_Click
>> >
>> >    Dim stDocName As String
>> >
>> >    stDocName = "QryUpd_ClearSA1Flag1"
>> >    DoCmd.OpenQuery stDocName, acNormal, acEdit
>> >    Me.Requery
>> >    'DoCmd.OpenQuery stDocName, acNormal, acEdit
>> >
>> >
>> > Exit_btn_ClSA1Flag1_Click:
>> >    Exit Sub
>> >
>> > Err_btn_ClSA1Flag1_Click:
>> >    msgbox Err.Description
>> >    Resume Exit_btn_ClSA1Flag1_Click
>> >
>> > End Sub
>> >
>> >
>> > As it is, if I am in the last record that was "Flagged" and I click on 
>> > the
>> > clear button, that records Flag field does not get cleared.  But when I
>> > uncomment the second docmd.runquery (which runs the update query that
>> > clears
>> > the flag field) it clears everything because I am no longer on the last
>> > flagged records flag field.  How do I get the last flagged field 
>> > cleared,
>> > without having to move off of the record and running the docmd.runquery
>> > twice??
>> >
>> > Thanks for your help.
>> >
>> > Emma
>> > -- 
>> > www.bardpv.com
>> > Tempe, Arizona
>>
>> 

0
Allen
6/28/2007 5:26:05 PM
Hi Allen,

That's where I got this SQL statement. but I've modified it to allow the 
user to enter in parameters, so that I don't have to have a Clear button for 
each of the 9 Flag fields.  This way the user selects the Flag field they 
want to clear then enters the flag text they want cleared in that flag field. 
 However, I am getting the Update syntax error message and I can't figure out 
why.  
-- 
www.bardpv.com
Tempe, Arizona


"Allen Browne" wrote:

> To get a sample SQL statement, you can mock up a query and switch to SQL 
> View (View menu.)
> 
> For an explanation of how to handle the quotes, see:
>     Quotation marks within quotes
> at:
>     http://allenbrowne.com/casu-17.html
> 
> -- 
> Allen Browne - Microsoft MVP.  Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
> 
> "Emma Aumack" <emma.aumack@crbard.com> wrote in message
> news:6697239B-A57D-4340-8678-5155F8D9678B@microsoft.com...
> > Thank you Allen!
> >
> > I like your code much better.  However, I am getting an error in the SQL
> > Update statement.  Think you could help me out?  Quotations just kill me.
> >
> > Please see the updated code below:
> >
> > Private Sub btn_ClFlag_Click()
> > On Error GoTo Err_btn_ClFlag_Click
> >
> >    Dim strSQL As String
> >    Dim flgField As String
> >
> >    flgField = InputBox("Enter Flag #:", "Flag Field")
> >    txtFlgfield = InputBox("Enter Flag Criteria to be Cleared.  i.e.",
> > "Clear Flag" & flgField)
> >
> >    If Me.Dirty Then
> >        Me.Dirty = False
> >    End If
> >
> >    strSQL = "UPDATE Tbl_Contacts SET Tbl_Contacts.Flag" & _
> >        flgField & "WHERE (((Tbl_Contacts.Flag" & flgField & ") = " &
> > txtFlgField & "));"
> >
> >    DBEngine(0)(0).Execute strSQL, dbFailOnError
> >
> >    Me.Requery
> >
> >
> > Exit_btn_ClFlag_Click:
> >    Exit Sub
> >
> > Err_btn_ClFlag_Click:
> >    msgbox Err.Description
> >    Resume Exit_btn_ClFlag_Click
> >
> > End Sub
> >
> > Thank you again!
> >
> > -- 
> > www.bardpv.com
> > Tempe, Arizona
> >
> >
> > "Allen Browne" wrote:
> >
> >> Is there any chance the current record in the form might be unsaved?
> >>
> >> Assuming your form is bound, try inserting this code on a new line after 
> >> the
> >> DIM line:
> >>     If Me.Dirty Then Me.Dirty = False
> >>
> >> Instead of OpenQuery, you could also try this:
> >>     dbEngine(0)(0).Execute stDocName, dbFailOnError
> >> which should notify you if the query is not able to update all the 
> >> records.
> >> For an explanation of this, see:
> >>     Action queries: suppressing dialogs, while knowing results
> >> at:
> >>     http://allenbrowne.com/ser-60.html
> >>
> >> -- 
> >> Allen Browne - Microsoft MVP.  Perth, Western Australia
> >> Tips for Access users - http://allenbrowne.com/tips.html
> >> Reply to group, rather than allenbrowne at mvps dot org.
> >>
> >> "Emma Aumack" <emma.aumack@crbard.com> wrote in message
> >> news:4EC3EC7A-4B44-49CA-9C5A-D8877ECD03B4@microsoft.com...
> >> > Hi All,
> >> >
> >> > I have a form on which there are several "Flag" text fields which users
> >> > use
> >> > to mark records.  Next to each flag field there is a clear button that
> >> > runs
> >> > the following code:
> >> >
> >> > Private Sub btn_ClSA1Flag1_Click()
> >> > On Error GoTo Err_btn_ClSA1Flag1_Click
> >> >
> >> >    Dim stDocName As String
> >> >
> >> >    stDocName = "QryUpd_ClearSA1Flag1"
> >> >    DoCmd.OpenQuery stDocName, acNormal, acEdit
> >> >    Me.Requery
> >> >    'DoCmd.OpenQuery stDocName, acNormal, acEdit
> >> >
> >> >
> >> > Exit_btn_ClSA1Flag1_Click:
> >> >    Exit Sub
> >> >
> >> > Err_btn_ClSA1Flag1_Click:
> >> >    msgbox Err.Description
> >> >    Resume Exit_btn_ClSA1Flag1_Click
> >> >
> >> > End Sub
> >> >
> >> >
> >> > As it is, if I am in the last record that was "Flagged" and I click on 
> >> > the
> >> > clear button, that records Flag field does not get cleared.  But when I
> >> > uncomment the second docmd.runquery (which runs the update query that
> >> > clears
> >> > the flag field) it clears everything because I am no longer on the last
> >> > flagged records flag field.  How do I get the last flagged field 
> >> > cleared,
> >> > without having to move off of the record and running the docmd.runquery
> >> > twice??
> >> >
> >> > Thanks for your help.
> >> >
> >> > Emma
> >> > -- 
> >> > www.bardpv.com
> >> > Tempe, Arizona
> >>
> >> 
> 
> 
0
Utf
6/28/2007 5:50:01 PM
Okay, I think I've figured out the SQL statement error.  I had not told the 
Update query what to SET the text in the txtFlgField to.

But now I'm getting the error:

"Too Few parameters. Expected 1"  when I put a "1" in the flgFieldNo 
inputbox and some text to be cleared in the txtFlgField input box.

Is my inputbox code right?

Again, here is the updated code:

Private Sub btn_ClFlag_Click()
On Error GoTo Err_btn_ClFlag_Click

    Dim strSQL As String
    Dim flgFieldNo As String
    Dim txtFlgfield As String
    
    flgFieldNo = InputBox("Enter Flag #:", "Flag Field")
    txtFlgfield = InputBox("Enter Flag Criteria to be Cleared.", "Clear 
Flag" & flgFieldNo)
        
    If Me.Dirty Then
        Me.Dirty = False
    End If
       
    strSQL = "UPDATE Tbl_Contacts SET Tbl_Contacts.Flag" & _
        flgFieldNo & " ="""" WHERE ((Tbl_Contacts.Flag" & flgFieldNo & ") = 
" & txtFlgfield & ");"
    
    DBEngine(0)(0).Execute strSQL, dbFailOnError
    
    Me.Requery

Exit_btn_ClFlag_Click:
    Exit Sub
 
Err_btn_ClFlag_Click:
    msgbox Err.Description
    Resume Exit_btn_ClFlag_Click
    
End Sub


-- 
www.bardpv.com
Tempe, Arizona


"Emma Aumack" wrote:

> Hi Allen,
> 
> That's where I got this SQL statement. but I've modified it to allow the 
> user to enter in parameters, so that I don't have to have a Clear button for 
> each of the 9 Flag fields.  This way the user selects the Flag field they 
> want to clear then enters the flag text they want cleared in that flag field. 
>  However, I am getting the Update syntax error message and I can't figure out 
> why.  
> -- 
> www.bardpv.com
> Tempe, Arizona
> 
> 
> "Allen Browne" wrote:
> 
> > To get a sample SQL statement, you can mock up a query and switch to SQL 
> > View (View menu.)
> > 
> > For an explanation of how to handle the quotes, see:
> >     Quotation marks within quotes
> > at:
> >     http://allenbrowne.com/casu-17.html
> > 
> > -- 
> > Allen Browne - Microsoft MVP.  Perth, Western Australia
> > Tips for Access users - http://allenbrowne.com/tips.html
> > Reply to group, rather than allenbrowne at mvps dot org.
> > 
> > "Emma Aumack" <emma.aumack@crbard.com> wrote in message
> > news:6697239B-A57D-4340-8678-5155F8D9678B@microsoft.com...
> > > Thank you Allen!
> > >
> > > I like your code much better.  However, I am getting an error in the SQL
> > > Update statement.  Think you could help me out?  Quotations just kill me.
> > >
> > > Please see the updated code below:
> > >
> > > Private Sub btn_ClFlag_Click()
> > > On Error GoTo Err_btn_ClFlag_Click
> > >
> > >    Dim strSQL As String
> > >    Dim flgField As String
> > >
> > >    flgField = InputBox("Enter Flag #:", "Flag Field")
> > >    txtFlgfield = InputBox("Enter Flag Criteria to be Cleared.  i.e.",
> > > "Clear Flag" & flgField)
> > >
> > >    If Me.Dirty Then
> > >        Me.Dirty = False
> > >    End If
> > >
> > >    strSQL = "UPDATE Tbl_Contacts SET Tbl_Contacts.Flag" & _
> > >        flgField & "WHERE (((Tbl_Contacts.Flag" & flgField & ") = " &
> > > txtFlgField & "));"
> > >
> > >    DBEngine(0)(0).Execute strSQL, dbFailOnError
> > >
> > >    Me.Requery
> > >
> > >
> > > Exit_btn_ClFlag_Click:
> > >    Exit Sub
> > >
> > > Err_btn_ClFlag_Click:
> > >    msgbox Err.Description
> > >    Resume Exit_btn_ClFlag_Click
> > >
> > > End Sub
> > >
> > > Thank you again!
> > >
> > > -- 
> > > www.bardpv.com
> > > Tempe, Arizona
> > >
> > >
> > > "Allen Browne" wrote:
> > >
> > >> Is there any chance the current record in the form might be unsaved?
> > >>
> > >> Assuming your form is bound, try inserting this code on a new line after 
> > >> the
> > >> DIM line:
> > >>     If Me.Dirty Then Me.Dirty = False
> > >>
> > >> Instead of OpenQuery, you could also try this:
> > >>     dbEngine(0)(0).Execute stDocName, dbFailOnError
> > >> which should notify you if the query is not able to update all the 
> > >> records.
> > >> For an explanation of this, see:
> > >>     Action queries: suppressing dialogs, while knowing results
> > >> at:
> > >>     http://allenbrowne.com/ser-60.html
> > >>
> > >> -- 
> > >> Allen Browne - Microsoft MVP.  Perth, Western Australia
> > >> Tips for Access users - http://allenbrowne.com/tips.html
> > >> Reply to group, rather than allenbrowne at mvps dot org.
> > >>
> > >> "Emma Aumack" <emma.aumack@crbard.com> wrote in message
> > >> news:4EC3EC7A-4B44-49CA-9C5A-D8877ECD03B4@microsoft.com...
> > >> > Hi All,
> > >> >
> > >> > I have a form on which there are several "Flag" text fields which users
> > >> > use
> > >> > to mark records.  Next to each flag field there is a clear button that
> > >> > runs
> > >> > the following code:
> > >> >
> > >> > Private Sub btn_ClSA1Flag1_Click()
> > >> > On Error GoTo Err_btn_ClSA1Flag1_Click
> > >> >
> > >> >    Dim stDocName As String
> > >> >
> > >> >    stDocName = "QryUpd_ClearSA1Flag1"
> > >> >    DoCmd.OpenQuery stDocName, acNormal, acEdit
> > >> >    Me.Requery
> > >> >    'DoCmd.OpenQuery stDocName, acNormal, acEdit
> > >> >
> > >> >
> > >> > Exit_btn_ClSA1Flag1_Click:
> > >> >    Exit Sub
> > >> >
> > >> > Err_btn_ClSA1Flag1_Click:
> > >> >    msgbox Err.Description
> > >> >    Resume Exit_btn_ClSA1Flag1_Click
> > >> >
> > >> > End Sub
> > >> >
> > >> >
> > >> > As it is, if I am in the last record that was "Flagged" and I click on 
> > >> > the
> > >> > clear button, that records Flag field does not get cleared.  But when I
> > >> > uncomment the second docmd.runquery (which runs the update query that
> > >> > clears
> > >> > the flag field) it clears everything because I am no longer on the last
> > >> > flagged records flag field.  How do I get the last flagged field 
> > >> > cleared,
> > >> > without having to move off of the record and running the docmd.runquery
> > >> > twice??
> > >> >
> > >> > Thanks for your help.
> > >> >
> > >> > Emma
> > >> > -- 
> > >> > www.bardpv.com
> > >> > Tempe, Arizona
> > >>
> > >> 
> > 
> > 
0
Utf
6/28/2007 6:02:02 PM
Got it working!  Thanks for your help
-- 
www.bardpv.com
Tempe, Arizona


"Emma Aumack" wrote:

> Hi Allen,
> 
> That's where I got this SQL statement. but I've modified it to allow the 
> user to enter in parameters, so that I don't have to have a Clear button for 
> each of the 9 Flag fields.  This way the user selects the Flag field they 
> want to clear then enters the flag text they want cleared in that flag field. 
>  However, I am getting the Update syntax error message and I can't figure out 
> why.  
> -- 
> www.bardpv.com
> Tempe, Arizona
> 
> 
> "Allen Browne" wrote:
> 
> > To get a sample SQL statement, you can mock up a query and switch to SQL 
> > View (View menu.)
> > 
> > For an explanation of how to handle the quotes, see:
> >     Quotation marks within quotes
> > at:
> >     http://allenbrowne.com/casu-17.html
> > 
> > -- 
> > Allen Browne - Microsoft MVP.  Perth, Western Australia
> > Tips for Access users - http://allenbrowne.com/tips.html
> > Reply to group, rather than allenbrowne at mvps dot org.
> > 
> > "Emma Aumack" <emma.aumack@crbard.com> wrote in message
> > news:6697239B-A57D-4340-8678-5155F8D9678B@microsoft.com...
> > > Thank you Allen!
> > >
> > > I like your code much better.  However, I am getting an error in the SQL
> > > Update statement.  Think you could help me out?  Quotations just kill me.
> > >
> > > Please see the updated code below:
> > >
> > > Private Sub btn_ClFlag_Click()
> > > On Error GoTo Err_btn_ClFlag_Click
> > >
> > >    Dim strSQL As String
> > >    Dim flgField As String
> > >
> > >    flgField = InputBox("Enter Flag #:", "Flag Field")
> > >    txtFlgfield = InputBox("Enter Flag Criteria to be Cleared.  i.e.",
> > > "Clear Flag" & flgField)
> > >
> > >    If Me.Dirty Then
> > >        Me.Dirty = False
> > >    End If
> > >
> > >    strSQL = "UPDATE Tbl_Contacts SET Tbl_Contacts.Flag" & _
> > >        flgField & "WHERE (((Tbl_Contacts.Flag" & flgField & ") = " &
> > > txtFlgField & "));"
> > >
> > >    DBEngine(0)(0).Execute strSQL, dbFailOnError
> > >
> > >    Me.Requery
> > >
> > >
> > > Exit_btn_ClFlag_Click:
> > >    Exit Sub
> > >
> > > Err_btn_ClFlag_Click:
> > >    msgbox Err.Description
> > >    Resume Exit_btn_ClFlag_Click
> > >
> > > End Sub
> > >
> > > Thank you again!
> > >
> > > -- 
> > > www.bardpv.com
> > > Tempe, Arizona
> > >
> > >
> > > "Allen Browne" wrote:
> > >
> > >> Is there any chance the current record in the form might be unsaved?
> > >>
> > >> Assuming your form is bound, try inserting this code on a new line after 
> > >> the
> > >> DIM line:
> > >>     If Me.Dirty Then Me.Dirty = False
> > >>
> > >> Instead of OpenQuery, you could also try this:
> > >>     dbEngine(0)(0).Execute stDocName, dbFailOnError
> > >> which should notify you if the query is not able to update all the 
> > >> records.
> > >> For an explanation of this, see:
> > >>     Action queries: suppressing dialogs, while knowing results
> > >> at:
> > >>     http://allenbrowne.com/ser-60.html
> > >>
> > >> -- 
> > >> Allen Browne - Microsoft MVP.  Perth, Western Australia
> > >> Tips for Access users - http://allenbrowne.com/tips.html
> > >> Reply to group, rather than allenbrowne at mvps dot org.
> > >>
> > >> "Emma Aumack" <emma.aumack@crbard.com> wrote in message
> > >> news:4EC3EC7A-4B44-49CA-9C5A-D8877ECD03B4@microsoft.com...
> > >> > Hi All,
> > >> >
> > >> > I have a form on which there are several "Flag" text fields which users
> > >> > use
> > >> > to mark records.  Next to each flag field there is a clear button that
> > >> > runs
> > >> > the following code:
> > >> >
> > >> > Private Sub btn_ClSA1Flag1_Click()
> > >> > On Error GoTo Err_btn_ClSA1Flag1_Click
> > >> >
> > >> >    Dim stDocName As String
> > >> >
> > >> >    stDocName = "QryUpd_ClearSA1Flag1"
> > >> >    DoCmd.OpenQuery stDocName, acNormal, acEdit
> > >> >    Me.Requery
> > >> >    'DoCmd.OpenQuery stDocName, acNormal, acEdit
> > >> >
> > >> >
> > >> > Exit_btn_ClSA1Flag1_Click:
> > >> >    Exit Sub
> > >> >
> > >> > Err_btn_ClSA1Flag1_Click:
> > >> >    msgbox Err.Description
> > >> >    Resume Exit_btn_ClSA1Flag1_Click
> > >> >
> > >> > End Sub
> > >> >
> > >> >
> > >> > As it is, if I am in the last record that was "Flagged" and I click on 
> > >> > the
> > >> > clear button, that records Flag field does not get cleared.  But when I
> > >> > uncomment the second docmd.runquery (which runs the update query that
> > >> > clears
> > >> > the flag field) it clears everything because I am no longer on the last
> > >> > flagged records flag field.  How do I get the last flagged field 
> > >> > cleared,
> > >> > without having to move off of the record and running the docmd.runquery
> > >> > twice??
> > >> >
> > >> > Thanks for your help.
> > >> >
> > >> > Emma
> > >> > -- 
> > >> > www.bardpv.com
> > >> > Tempe, Arizona
> > >>
> > >> 
> > 
> > 
0
Utf
6/28/2007 9:42:01 PM
Reply:

Similar Artilces:

updating sheets based on data in first sheet
Another payroll question, I have a workbook that contains 26 sheets, one for each bi-weekl payroll period. I would like to set it up so when i add a new employe the rest of the sheets also update automatically with that employee name and information. I have been able to acheive this to a limited degree using th =sheet1!a1 formula, but this only updates the info in the first cel and particularly the first column. I would like to acheive this using the first sheet, since at th end of the year I would like to be able to calculate ytd figure easily. Thank -- Message posted from http://www.Exc...

Update for MS Money 2005?
I have Money 2005. Is there an update to MS Money for Canadian users? Thanks in advance for any answers. We need a bit more information! Are you having problems with M2005 or is this just a post-Christmas/New Year random query when you are trying to get away from the in-laws? -- Regards Bob Peel, Microsoft MVP - Money For unofficial FAQs see http://money.mvps.org/ or http://umpmfaq.info/ I do not respond to any emails that I have not specifically asked for. "Daniel" <Daniel@discussions.microsoft.com> wrote in message news:E86EAB89-21DE-4505-ACAD-647278D736BD@microso...

Problem with Script Updating
I am using a script to update the “1099 Type” field for Master Vendor table. The script basically is a basic if-then statement. This script is run “Before Document Commit” and it’s not updating correctly, its flip-flopping the results. When the script is set to run Before Document Commit I have the “Destination mapping” field “1099 Type” set to “Use Script”. Script below: If SourceFields("Send 1099") = "N" Then DestinationFields("Options.1099 Type").Value = 1 Else DestinationFields("Options.1099 Type").Value = 4 End If I have also tried this s...

Microsoft Update only updates Windows Defender
iacrosoft Update only updates Windows Defender - I have to use Belarc Advisor to get a list of missing updates, and then go to the Microsoft Download Center to search for the missing updates and download and install them one at a time. I have Windows XP Home SP3, with Microsoft Update set to automatic download - can anyone tell me why I do not get all the necessary upadtes? Is this a sudden, new problem? When was Automatic Updates last working? Can you update manually via http://windowsupdate.microsoft.com? Any chance you've got a beta build of WinXP SP3 installed? What...

Publisher 2007 and Microsoft Updates
I created a newsletter yesterday - everything fine - use Publisher all the time. Then an automatic update came down this morning and I can't open the file - it says "Publisher cannot open file" Other documents in Publisher are opening - any ideas? http://support.microsoft.com/kb/972566/ -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "Kim" <Kim@discussions.microsoft.com> wrote in message news:8754339B-99DC-4D09-83AD-6B34D8215274@microsoft.com... >I created a newsletter yesterday - everythin...

Update question
Soory if this is the wrong place to ask this, but cannot find a NG proper to Windows 7. I currently run Windows Vista and am getting tired of Vista's decision to tell me that it is going to shut down in less than a minute. So have decided to upgrade to Windows &. I note that I can purchase an upgrade versiom for 64 quid from Amazon or an apparently full version of Windows 7 Home premium for 89 quid. My question is this - If I buy the upgrade version will I only be able to load it on a new PC in the future if I already have windows Vista installed? i.e For any future cl...

SELECT query as subquery to APPEND
I am trying to use a SELECT query as a subquery to an APPEND query to create a dynaset on the fly and append it into tblEmployeeProduction from the click of a button on a form. The only thing is that my SELECT query takes one parameter and because of that I am unsure how to set up the APPEND portion of the query or if it can be done at all. Here are the opening lines of the SELECT's SQL: PARAMETERS forms![frmSetEmpHours]![txtDate] DateTime; SELECT [FirstName] & " " & [LastName] AS Name, forms!frmSetEmpHours! txtDate AS ProductionDate, 'Do more stuff here.............

Outlook 2003 died mysteriously after update
Setup in a nutshell... System: Lenovo T500 laptop OS: Vista Business SP1 32-bit Software: Office Outlook 2003 SP3 Problem... So I'm using this setup for over a year, everything OK. Yesterday I did two things and now Outlook dies (quietly, sans error message) immediately after startup. It show the splash screen, displays my inbox, and *poof* disappears. What I did earlier... 1. Windows Update installed: KB9766662, KB979306, KB979099, KB975929 2. At the same time, while searching for another program to uninstall I stumbled upon (and uninstalled) Windows LIVE Toolbar and...

How update entity in post update?
I created a handler for Update post callout for Opportunity. I want update some fields of the opportunity on the PostUpdate. However, if I call the Update method of CRMOpportunity in the PostUpdate I will create a recursive post callout. Can somebody help me? Thank you for pay attention []'s Vin�cius Pitta Lima de Ara�jo You need to check the OrigObjectXML field to see what fields were updated and then act appropriately. Matt Parks MVP - Microsoft CRM ---------------------------------------- ---------------------------------------- On Wed, 4 Aug 2004 17:43:17 -0300, "Vin�cius ...

Any way to make the web query refresh to be done in the background?
currently when refreshing the data ... the mouse pointer will be bus and nothing i can do until it finish ... any way to set it so that i can do in the background without distrubing my interaction ? Thank if anyone can help .. Regards -- kitste ----------------------------------------------------------------------- kitster's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1495 View this thread: http://www.excelforum.com/showthread.php?threadid=26912 ...

Cannot install update KB979906 for .NET Framework 1.1 SP1
Running : Windows XP media center edition SP3 Have tried installing KB979906 a few times and also downloaded update manually but cannot install this update. Receiving error 0x643.Is it safe to uninstall the .NET Framework 1.1 and re-install as possibly corrupt , without having to uninstall/re-install all other .NET frameworks 2 , 3 and 3.5 including the updates that go with them? .. Hello sherlockomes, you might want to look at the following kb article to see if this will help with the error 80070643. <http://windows.microsoft.com/en-US/windows-vista/Windows-Update-error...

Print record once, update Yes/No field verifiying print
I would like to print a group of records, then have a Yes/No field [Printed] updated in my Jobs table with an update query showing the records were printed. Then next time the report runs, In my query criteria I will test for True values on the Yes/No field. Then only the records with the Yes/No field marked No will print. Any suggestions? Thanks Tommyboy,there's more to this question than meets the eye. For an explanation of what's involved, see: Has the record been printed? at: http://allenbrowne.com/ser-72.html The article includes a free sample database that dem...

latest update too MSCFV2
Hi, I have MSCFV2 version 6.5.7825.0. Could someone inform me if this is the latest download? Looks like you have 6.5.7825.0 from 05/21/2006, but there is a newer version - 6.5.7831.0 from 06/01/2006. C. Smith Enso Technologies, Incorporated http://www.ensotech.com On Tue, 13 Jun 2006 04:25:02 -0700, Paul <Paul@discussions.microsoft.com> wrote: >Hi, > >I have MSCFV2 version 6.5.7825.0. Could someone inform me if this is the >latest download? Christopher Smith csmith@ensotech.com Enso Technologies, Incorporated http://www.ensotech.com Also - meant to post this in t...

Dynamic Menu update
Hi All, I need to update a menu item dynamically, setting its SetCheck property to either true or false, based on a user operation. I am trying to do this from a custom function. Usually, the pCmdUI pointer is used. But how do I do it from another function? Thanks Your "other function" should change some setting. In your ON_UPDATE_COMMAND_UI handler, you should check that setting and call SetCheck as needed. -------------- Ajay Kalra ajaykalra@yahoo.com In addition to Ajay's response, this page may help you: http://msdn2.microsoft.com/en-us/library/6kc4d8f...

online updates for money2003(not updating)
Money gets its updates from spcomstock.com and the server has moved to a new site. The default site that money provides has to be changed. At this time I don't know how to do this. If I find out how to do this I will Post it. ...

Payroll Update
HI all, We are running GP 7.5. I installed SP7 and the July 2005 tax update for CDN payroll. Now out payroll administrator gets an error message: 'The modified version of P_Payroll registry is missing'. How do I fix this problem Thanks -- Henry ...

[ANN] Excel X security update
Hi All, A security update for Excel X was also released today: http://www.microsoft.com/mac/downloads.aspx?pid=download&location=/mac/d ownload/officex/ExcelX_Security_1017.xml&secid=5&ssid=17&flgnosysreq=Tru e Or at least: http://www.microsoft.com/mac/downloads.aspx Corentin -- --- Mac:MS MVP (Francophone) --- http://www.mvps.org - http://mvp.support.microsoft.com MVPs are not MS employees - Les MVP ne travaillent pas pour MS Remove "NoSpam" to e-mail me - Retirez "NoSpam" pour m'�crire ...

FWD: Try on these correction update from the MS Corp.
--omvflfmgecbtuznop Content-Type: multipart/related; boundary="pesxyyfvxtk"; type="multipart/alternative" --pesxyyfvxtk Content-Type: multipart/alternative; boundary="locjfxspwlfruwcg" --locjfxspwlfruwcg Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Microsoft Client this is the latest version of security update, the "October 2003, Cumulative Patch" update which fixes all known security vulnerabilities affecting MS Internet Explorer, MS Outlook and MS Outlook Express. Install now to continue keeping your computer secure from th...

Business Portal Query Security
I need to create payroll & HR queries for users, but I do not want them to have the ability to modify queries or to create new queries. Patti, Thanks for using the newsgroups. I wouldn't suggest tring to secure your data by not allowing users to create or modify queries. The best way to secure your data is through the data permissions. Only give users data permissions they should have. You can create new data permissions and take away properties if appropriate. Finally, BP has out of the box data permissions called "XXXX-Restricted Self". This means the user can...

HOW ABOUT AN UPDATE?
Microsoft, can we get an update on the login issue please???? It's been a whole day since we heard from Russ last. Err, Russ sent 2 updates today. Subject line = "File Lock Update" Hope you can find them. "shan" <anonymous@discussions.microsoft.com> wrote in message news:6bef01c475b3$3e7d6ea0$a601280a@phx.gbl... > Microsoft, can we get an update on the login issue > please???? It's been a whole day since we heard from > Russ last. >-----Original Message----- Look again, he posted 2 yesterday, we are still waiting for something today...

Cannot Update office
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: intel When I try to update office a message appears saying that a version of the software needed to udate microsoft office is not available. What is this and what can be done to correct it I have the same problem with Tiger 10.4.11. "efrosini@officeformac.com" wrote: > Version: 2008 > Operating System: Mac OS X 10.5 (Leopard) > Processor: intel > > When I try to update office a message appears saying that a version of the software needed to udate microsoft office is not available. What is this and ...

Cannot update table--only does SQL insert
Hi, just another newbie type of question.... i have a new window with its own table. i'm doing a "copy from window to table" &c, and it works fine to insert data the first time. however, i can tell from the SQL Profiler that when I try to modify the data, it does not do an update--it tries to do another insert (and of course, can't). Is there something I should be setting in Dexterity somewhere to make the table updatable, or do I need to manage this with PassThroughSQL? thanks in advance. Table operations are covered in detail during the Dexterity Training, pl...

automatically update field
Hi I have a combo box with two columns - product & stock code. When I select a product I want the the stock code column which I have in my table to automatically populate. Is this possible to have on the actual main table? -- Thank you for your help Yes - you could use the AfterUpdate event of the combo to set the value of the control bound to the field holding the stock code. But - why ? You already have the stock code so it seems you want to store it again (twice in the same table or - even worse - in another table). Both of these are very bad ideas. You should use the rel...

Recorset not updateable in a crosstab query
I have created a crosstab query based on just one linked table using the Access wizard and when I finished I get the erro "The recorset is not updateable", clicking on OK it shows me the tahe results in the corresponding table, but if I try to see the structure of the query it shows me the structure mask but saying that in the expression "Format([DPC]:"aaaa")" there to many closing brackets. I copied the table to the current DB to avoid any links problems but the result is the same. Can anybody tell me how to solve the problem? Thanks very muc...

Problems Updating to Visual Studio 2008
I've previously used Visual C++ 4 and have now updated to Visual Studio 2008. In Visual C++ 4, I used the Class Wizard with its five tabs: Message Maps, Member Variables, OLE Automation, OLE Events, and Class Info to define an application. This structure doesn't seem to exist in Visual Studio 2008. Can anyone explain, or point me to information about, how I can get to the same functionality in Visual Studio 2008? I'd also welcome any suggestions for a book I might purchase that explains how to use Visual C++ as implemented in Visual Studio 2008. Gordon P "Gordon P...