PC Review


Reply
Thread Tools Rate Thread

How can I commit a data change without requerying the form?

 
 
Dave
Guest
Posts: n/a
 
      12th Jun 2004
I have a combobox on a subform that is displayed as continuous forms in the
parent form.

When a user makes a selection in the combobox, the afterupdate event fires
and executes a SQL query using ADO objects. The SQL query using the ID from
the combo box selection as part of its WHERE clause.

I am having a problem with event timing.

When the SQL code executes, the ID specified in the combobox has not been
written to the database yet. So no records are returned because the ID
specified in the WHERE clause does not yet exist in the database and my
query operates on an empty set.

If I add a Me.Requery to my code, the ID is written to the database and
everything works fine for the first record. However, the Requery reloads the
subform, making the first record the active record. So when I reference the
ID in the cbo, I am now referencing the ID of the first record, not the ID
of a subsequent record I was working with before the requery. My WHERE
clause nows operates on all the records that match the first record's ID,
not the ID of the record I was working with before the requery.

I can probably work around this by using a global variable or bookmark to
store the ID before I requery. However, this seems like a hack. Does anyone
know a cleaner way to approach this?


 
Reply With Quote
 
 
 
 
Dave
Guest
Posts: n/a
 
      12th Jun 2004
Never mind. A local variable seems to work fine.

But I am curious .if it is possible to commit without requerying if anyone
knows.



 
Reply With Quote
 
Ken Snell
Guest
Posts: n/a
 
      12th Jun 2004
Replace the Me.Requey line with this line:
If Me.Dirty = True Then Me.Dirty = False

That will write a record that is being edited to the table.

--

Ken Snell
<MS ACCESS MVP>

"Dave" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Never mind. A local variable seems to work fine.
>
> But I am curious .if it is possible to commit without requerying if anyone
> knows.
>
>
>



 
Reply With Quote
 
Dave
Guest
Posts: n/a
 
      13th Jun 2004
Thanks Ken



"Ken Snell" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Replace the Me.Requey line with this line:
> If Me.Dirty = True Then Me.Dirty = False
>
> That will write a record that is being edited to the table.
>
> --
>
> Ken Snell
> <MS ACCESS MVP>
>
> "Dave" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Never mind. A local variable seems to work fine.
> >
> > But I am curious .if it is possible to commit without requerying if

anyone
> > knows.
> >
> >
> >

>
>




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: requerying a main form calculated fields from after subform data entry Allen Browne Microsoft Access Forms 2 21st Jan 2010 06:14 AM
requerying a form johnlute Microsoft Access Form Coding 0 2nd Jan 2010 11:10 PM
Requerying a form =?Utf-8?B?QmxhaXI=?= Microsoft Access Forms 3 28th Nov 2005 08:26 PM
Form requerying Junior Microsoft Access Form Coding 1 5th Aug 2005 01:02 AM
Requerying one form from another jonesy Microsoft Access 1 19th Sep 2003 11:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:24 PM.