473,379 Members | 1,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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 1702
you'll need to capture the criteria and programmatically 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 = thebatchcriteria
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!MyCriteriaForm!MyBatchCriteriaControl

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.googlegr oups.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 programmatically 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 = thebatchcriteria
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!MyCriteriaForm!MyBatchCriteriaControl

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
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...
5
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...
4
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...
1
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...
1
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...
10
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...
1
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...
47
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...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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 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.