473,569 Members | 2,590 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help - Updateable query adds new row with missing criteria fields

JM
Hello,

I've created a Querydef in a Form_Load() sub. The form is a subform
that no longer has linked child fields. The form is bound to this
querydef. When I open the form, the fields are populated just fine.
However, when I add a new record using the new record control at the
bottom of the subform, it gets added with NULL for the two values that
were in the original WHERE clause.

For example, if my query was "SELECT batch, style, serial_no,
warehouse, color from chair_inventory WHERE batch = 138 and style = 6",
the form is populated. Then, when I add a new record, it gets added
with the serial_no, warehouse, and color I specified, but batch and
style are NULL. How can I make the dynaset pick up the original
criteria and insert them?

Thanks,

JM

Nov 13 '05 #1
2 1712
you'll need to capture the criteria and programmaticall y insert it into the
proper fields in the new record. you can do this on the subform's Insert
event, or BeforeUpdate event, by just setting the value of the fields in
VBA. something like

Me!BatchField = thebatchcriteri a
Me!StyleField = the stylecriteria

how you capture the criteria depends on how you fed them to the query in the
first place. if you entered the criteria in controls on another form that
remains open, you can refer to those controls in the code directly, as
Forms!MyCriteri aForm!MyBatchCr iteriaControl

if you generated the criteria request in the subform's Load event, it should
be simple enough to save the return values into variables, so they're
available while the subform remains open.

hth
"JM" <jm***********@ yahoo.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Hello,

I've created a Querydef in a Form_Load() sub. The form is a subform
that no longer has linked child fields. The form is bound to this
querydef. When I open the form, the fields are populated just fine.
However, when I add a new record using the new record control at the
bottom of the subform, it gets added with NULL for the two values that
were in the original WHERE clause.

For example, if my query was "SELECT batch, style, serial_no,
warehouse, color from chair_inventory WHERE batch = 138 and style = 6",
the form is populated. Then, when I add a new record, it gets added
with the serial_no, warehouse, and color I specified, but batch and
style are NULL. How can I make the dynaset pick up the original
criteria and insert them?

Thanks,

JM

Nov 13 '05 #2
JM


tina wrote:
you'll need to capture the criteria and programmaticall y insert it into the
proper fields in the new record. you can do this on the subform's Insert
event, or BeforeUpdate event, by just setting the value of the fields in
VBA. something like

Me!BatchField = thebatchcriteri a
Me!StyleField = the stylecriteria

how you capture the criteria depends on how you fed them to the query in the
first place. if you entered the criteria in controls on another form that
remains open, you can refer to those controls in the code directly, as
Forms!MyCriteri aForm!MyBatchCr iteriaControl

if you generated the criteria request in the subform's Load event, it should
be simple enough to save the return values into variables, so they're
available while the subform remains open.

hth


Tina,

Thanks very much for the suggestion. I'll try it. I neglected to
mention that the table is SQL Server 2000 linked ODBC. When the table
was Access, the application worked as designed. I know the linked
table broke the Dynaset insert, and I wish I knew why. I hate when I
get asked to put a SQL Server back end on an Access front-end. Thanks
again.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1988
by: Marie | last post by:
Access97 I have a table containing addresses with a separate field for State. Is there a way to create a query that returns an unique list of the states in that table and still be updateable? I tried setting the unique values property to Yes but that gave me a recordset that was not updateable. Thanks! Marie
5
1491
by: Norma | last post by:
I am trying to make a query pull data from between the dates I enter in the parameter but also look back 'in time' to see where 2 other fields have null values, and only pull data into the query if those 2 fields are null prior to the beginning date of my parameter. The reason for this (to help make this a little clearer)is to pull production...
4
2268
by: Laura | last post by:
Here's the situation: I'm trying to use an update query to copy data from one row to another. Here is the situation: I have 5 companies that are linked to each other. I need to show all 5 companies on a form. 3 of the companies have common employees. I have a table that looks like this:
1
3143
by: James | last post by:
Access 2003, trying to count the number of records that meet a criteria. According to Help: "In the Database window, click Queries under Objects, and then click New on the database window toolbar. Add the table, view, or function you want to summarize in the Diagram pane. " OK, that's easy.....but then..... "Right-click the background...
1
1799
by: Ivan Carey | last post by:
How can a query display multiple fields with diferent condition on the same field example I have a field name of reason and a field name of duration. I would like to display 2 fileds of total duration but each have different reasion criteria. display Total Recall based on a calculation that adds the total duration for each record that...
10
2008
by: motessa | last post by:
Hello All, I am new to Access and have been looking for answers to my problem on the internet and have not found it yet. I hope someone can give me a hint. Thanks so much. I have a form (called: myform) in which there is a combo (combo1) and a button (button1). In properties for combo1, I use "Value List" for Row Source Type and in Row...
1
4595
by: melody.charlesworth | last post by:
I link fields in tables 1 and 2 (one to one or unmatched) in order to update fields in table 2 with others from table one. If I use criteria from one of these tables there is no problem but if I link in a 3rd table in order to retrict the action, I get an error message saying that the query is not updateable (if not something to do with...
47
2832
by: Jo | last post by:
Hi there, I'm Jo and it's the first time I've posted here. I'm in process of creating a database at work and have come a little unstuck.....I'm a bit of a novice and wondered if anyone could help. I work in a library and send out dual language books to babies of dual or other nationality. The db is to be used for logging a range of book...
1
3722
by: RussCRM | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for statistical purposes. I've been using Here’s the situation: I have two main tables: Guest (stores data such as GuestID, First Name, Last Name, etc.)...
0
7701
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8130
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.