I have an update query that runs when a report closes. I have several
reports that will need to run the update query with diferent criteria.
I'd like to simply make the criteria change in the report vba instead
of making different queries.
Here's my query sql:
UPDATE Draw SET Draw.Billed = Yes
WHERE (((Draw.Billed)=No) AND ((Draw.WholesalerName)="Hudson"));
And My code that runs the update query
DoCmd.OpenQuery "DrawBillUpdateQueryHudson"
How do I pass the criteria : ((Draw.WholesalerName)="Hudson")); via
the VBA in the report? 5 13177
On 1 Apr 2004 12:04:05 -0800, dj*******@hotmail.com (Don Seckler)
wrote: I have an update query that runs when a report closes. I have several reports that will need to run the update query with diferent criteria. I'd like to simply make the criteria change in the report vba instead of making different queries.
Here's my query sql:
UPDATE Draw SET Draw.Billed = Yes WHERE (((Draw.Billed)=No) AND ((Draw.WholesalerName)="Hudson"));
And My code that runs the update query
DoCmd.OpenQuery "DrawBillUpdateQueryHudson"
How do I pass the criteria : ((Draw.WholesalerName)="Hudson")); via the VBA in the report?
Why not just simply execute an SQL string instead of using a saved
query?
Dim strUpDate As String
strUpDate = "UPDATE Draw SET Draw.Billed = Yes " _
& "WHERE (((Draw.Billed)=No) AND ((Draw.WholesalerName)='Hudson'));"
'Note you need to use single quotes around text values
CurrentDb.Execute strUpDate, DbFailOnError
- Jim
Thanks Jim. I thought there was a more simple solution.
"Jim Allensworth" <ji****@Notdatacentricsolutions.com> wrote in message news:<40****************@news.west.earthlink.net>. .. On 1 Apr 2004 12:04:05 -0800, dj*******@hotmail.com (Don Seckler) wrote:
I have an update query that runs when a report closes. I have several reports that will need to run the update query with diferent criteria. I'd like to simply make the criteria change in the report vba instead of making different queries.
Here's my query sql:
UPDATE Draw SET Draw.Billed = Yes WHERE (((Draw.Billed)=No) AND ((Draw.WholesalerName)="Hudson"));
And My code that runs the update query
DoCmd.OpenQuery "DrawBillUpdateQueryHudson"
How do I pass the criteria : ((Draw.WholesalerName)="Hudson")); via the VBA in the report? Why not just simply execute an SQL string instead of using a saved query?
Dim strUpDate As String
strUpDate = "UPDATE Draw SET Draw.Billed = Yes " _ & "WHERE (((Draw.Billed)=No) AND ((Draw.WholesalerName)='Hudson'));" 'Note you need to use single quotes around text values
CurrentDb.Execute strUpDate, DbFailOnError
- Jim
Don
I'd do it Jim's way, but if you create a stored update query with a
parameter:[Name, or something] you can pass the parameter in code by
something like
Dim qdf As QueryDef
Set qdf = CurrentDb.QueryDefs("name of query")
qdf![Name] = "name"
qdf.Execute
set qdf = nothing
Neil dj*******@hotmail.com (Don Seckler) wrote in message news:<fe**************************@posting.google. com>... Thanks Jim. I thought there was a more simple solution.
"Jim Allensworth" <ji****@Notdatacentricsolutions.com> wrote in message news:<40****************@news.west.earthlink.net>. .. On 1 Apr 2004 12:04:05 -0800, dj*******@hotmail.com (Don Seckler) wrote:
I have an update query that runs when a report closes. I have several reports that will need to run the update query with diferent criteria. I'd like to simply make the criteria change in the report vba instead of making different queries.
Here's my query sql:
UPDATE Draw SET Draw.Billed = Yes WHERE (((Draw.Billed)=No) AND ((Draw.WholesalerName)="Hudson"));
And My code that runs the update query
DoCmd.OpenQuery "DrawBillUpdateQueryHudson"
How do I pass the criteria : ((Draw.WholesalerName)="Hudson")); via the VBA in the report? Why not just simply execute an SQL string instead of using a saved query?
Dim strUpDate As String
strUpDate = "UPDATE Draw SET Draw.Billed = Yes " _ & "WHERE (((Draw.Billed)=No) AND ((Draw.WholesalerName)='Hudson'));" 'Note you need to use single quotes around text values
CurrentDb.Execute strUpDate, DbFailOnError
- Jim
Neil,
Watch out using Name, it is an Access reserved keyword.
If you want to go the querydef route, put a parameter in the
WholesalerName field -- [TheName]. Now run it like ....
-------------------------------------
Dim qdf As QueryDef
Set qdf = CurrentDb.QueryDefs("DrawBillUpdateQueryHudson")
With qdf
.Parameters("TheName") = Me.WholesalerName
.Execute
End With
Set qdf = Nothing
-------------------------------
This assumes you have a field in the form's recordset named
"WholesalerName"
- Jim
On 6 Apr 2004 07:48:10 -0700, ne***********@boroughmuir.edin.sch.uk
(NeilAnderson) wrote: Don
I'd do it Jim's way, but if you create a stored update query with a parameter:[Name, or something] you can pass the parameter in code by something like Dim qdf As QueryDef Set qdf = CurrentDb.QueryDefs("name of query") qdf![Name] = "name" qdf.Execute set qdf = nothing
Neil
dj*******@hotmail.com (Don Seckler) wrote in message news:<fe**************************@posting.google. com>... Thanks Jim. I thought there was a more simple solution.
"Jim Allensworth" <ji****@Notdatacentricsolutions.com> wrote in message news:<40****************@news.west.earthlink.net>. .. > On 1 Apr 2004 12:04:05 -0800, dj*******@hotmail.com (Don Seckler) > wrote: > > >I have an update query that runs when a report closes. I have several > >reports that will need to run the update query with diferent criteria. > > I'd like to simply make the criteria change in the report vba instead > >of making different queries. > > > >Here's my query sql: > > > >UPDATE Draw SET Draw.Billed = Yes > >WHERE (((Draw.Billed)=No) AND ((Draw.WholesalerName)="Hudson")); > > > > > >And My code that runs the update query > > > >DoCmd.OpenQuery "DrawBillUpdateQueryHudson" > > > >How do I pass the criteria : ((Draw.WholesalerName)="Hudson")); via > >the VBA in the report? > Why not just simply execute an SQL string instead of using a saved > query? > > Dim strUpDate As String > > strUpDate = "UPDATE Draw SET Draw.Billed = Yes " _ > & "WHERE (((Draw.Billed)=No) AND ((Draw.WholesalerName)='Hudson'));" > 'Note you need to use single quotes around text values > > CurrentDb.Execute strUpDate, DbFailOnError > > - Jim
Jim's way is right of course. I always do it in code because a) you
can trap errors, b) troubleshoot it more easily c) you might, like me,
have a tendancy to say "what's that query for? delete it" or d) change
the stored query without realizing what you are doing.
Neil Ji****@NOTdatacentricsolutions.com (Jim Allensworth) wrote in message news:<40**************@netnews.comcast.net>... Neil,
Watch out using Name, it is an Access reserved keyword. If you want to go the querydef route, put a parameter in the WholesalerName field -- [TheName]. Now run it like ....
------------------------------------- Dim qdf As QueryDef
Set qdf = CurrentDb.QueryDefs("DrawBillUpdateQueryHudson") With qdf .Parameters("TheName") = Me.WholesalerName .Execute End With Set qdf = Nothing -------------------------------
This assumes you have a field in the form's recordset named "WholesalerName"
- Jim
On 6 Apr 2004 07:48:10 -0700, ne***********@boroughmuir.edin.sch.uk (NeilAnderson) wrote:
Don
I'd do it Jim's way, but if you create a stored update query with a parameter:[Name, or something] you can pass the parameter in code by something like Dim qdf As QueryDef Set qdf = CurrentDb.QueryDefs("name of query") qdf![Name] = "name" qdf.Execute set qdf = nothing
Neil
dj*******@hotmail.com (Don Seckler) wrote in message news:<fe**************************@posting.google. com>... Thanks Jim. I thought there was a more simple solution.
"Jim Allensworth" <ji****@Notdatacentricsolutions.com> wrote in message news:<40****************@news.west.earthlink.net>. .. > On 1 Apr 2004 12:04:05 -0800, dj*******@hotmail.com (Don Seckler) > wrote: > > >I have an update query that runs when a report closes. I have several > >reports that will need to run the update query with diferent criteria. > > I'd like to simply make the criteria change in the report vba instead > >of making different queries. > > > >Here's my query sql: > > > >UPDATE Draw SET Draw.Billed = Yes > >WHERE (((Draw.Billed)=No) AND ((Draw.WholesalerName)="Hudson")); > > > > > >And My code that runs the update query > > > >DoCmd.OpenQuery "DrawBillUpdateQueryHudson" > > > >How do I pass the criteria : ((Draw.WholesalerName)="Hudson")); via > >the VBA in the report? > Why not just simply execute an SQL string instead of using a saved > query? > > Dim strUpDate As String > > strUpDate = "UPDATE Draw SET Draw.Billed = Yes " _ > & "WHERE (((Draw.Billed)=No) AND ((Draw.WholesalerName)='Hudson'));" > 'Note you need to use single quotes around text values > > CurrentDb.Execute strUpDate, DbFailOnError > > - Jim This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Don Seckler |
last post by:
I have an update query that runs when a report closes. I have several
reports that will need to run the update query with diferent criteria.
I'd like to simply make the criteria change in the...
|
by: DFS |
last post by:
Architecture: Access 2003 client, Oracle 9i repository, no Access security
in place, ODBC linked tables.
100 or so users, in 3 or 4 groups (Oracle roles actually): Admins, Updaters
and ReadOnly....
|
by: ILCSP |
last post by:
Hello, I'm fairly new to the concept of running action pass through
queries (insert, update, etc.) from Access 2000. I have a SQL Server
2000 database and I'm using a Access 2K database as my...
|
by: ILCSP |
last post by:
Hello, I'm in the process of changing our 'normal' Access 2000 update
queries to Update Pass Through Queries. We have a SQL server 2000
database and we're using an Access 2000 database as our...
|
by: Josetta |
last post by:
This is for informational purposes...I had a problem and I thought it
might help others in a similar situation. I hope someone, someday,
finds this idea useful. I've garnered so much knowledge...
|
by: emgallagher |
last post by:
I have a form which lists studies. People can filter the form based
on
details about the study, such as the study type. Currently users
filter via
the right click method.
I would like to be...
|
by: lorirobn |
last post by:
Hi,
I have a list box on a form, whose row source points to a separate
query. The query refers to a field on the form to filter records on
the list box, like such: WHERE tblA.DesignType = !!...
|
by: Lewe22 |
last post by:
I am creating a small Access db which performs a series of updates to a SQL database.
The Access db consists of a ‘Main Form’, from which the user can run each update via a series of command...
|
by: pabs1111 |
last post by:
I'm trying to filter the records in a form using a pass through query.
strFilter = strFilter & "( eventid in (select FWIPEvent.eventid from FWIPEvent )) "
Me.Filter = strFilter
Me.FilterOn =...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |